Lab 2 Feedback
Marking scheme:
--------------------
1.8 / 2 -some unit tests failed; TAs, please check for errors
--------------------
TA Comments:
-getInterpretationOfBMI fails because you set this.bmi in the
method getBMI; if the client or tester does not call getBMI
then this.bmi is never set
--------------------
Style checker output:
YOUR SUBMISSION FAILED SOME BASIC STYLE CHECKS
Here is the style checker output:
Starting audit...
/home/burton/work/teaching/2017F/2030/marking/lab2/krease10/src/implementation/Person.java:15:28: '{' is not preceded with whitespace.
/home/burton/work/teaching/2017F/2030/marking/lab2/krease10/src/implementation/Person.java:26:27: '{' is not preceded with whitespace.
/home/burton/work/teaching/2017F/2030/marking/lab2/krease10/src/implementation/Person.java:33:47: '{' is not preceded with whitespace.
/home/burton/work/teaching/2017F/2030/marking/lab2/krease10/src/implementation/Person.java:35:37: '{' is not preceded with whitespace.
/home/burton/work/teaching/2017F/2030/marking/lab2/krease10/src/implementation/Person.java:38:57: '{' is not preceded with whitespace.
/home/burton/work/teaching/2017F/2030/marking/lab2/krease10/src/implementation/Person.java:41:57: '{' is not preceded with whitespace.
Audit done.
--------------------
Unit tester output:
YOUR SUMBISSION FAILED SOME UNIT TESTS
Here is the test output:
java -classpath .:/home/burton/work/teaching/2017F/2030/marking/lab2/_jar/* org.junit.runner.JUnitCore tests.Lab2Suite
JUnit version 4.12
......E....
Time: 0.553
There was 1 failure:
1) testGetBMIInterpretation(tests.TestPerson)
org.junit.ComparisonFailure: getInterpretationOfBMI() failed for weight = 20.000000 and height = 1.000000 expected:<[normal]> but was:<[underweight]>
FAILURES!!!
Tests run: 10, Failures: 1
--------------------
Your submission:
package implementation;
public class Person {
public String name;
double weight;
double height;
double bmi;
public Person(String name) {
// TODO Auto-generated constructor stub
this.name = name;
}
public String getName(){
return this.name;
}
public void setHeight(double height)throws IllegalArgumentException {
if (height <= 0) {
throw new IllegalArgumentException();
}
this.height = height;
}
public double getBMI(){
double res1 = this.weight / (Math.pow(this.height, 2));
double res2 = Math.round(res1 * 10);
this.bmi = res2 / 10;
return this.bmi;
}
public String getInterpretationOfBMI(){
if (this.bmi < 18.5){
return "underweight";
}
if (this.bmi >= 18.5 && this.bmi < 25.0){
return "normal";
}
if (this.bmi >= 25.0 && this.bmi < 30.0){
return "overweight";
}
return "obese";
}
public double getWeight() {
// TODO Auto-generated method stub
return this.weight;
}
public void setWeight(double weight) throws IllegalArgumentException {
if (weight <= 0) {
throw new IllegalArgumentException();
}
this.weight = weight;
}
public double getHeight() {
// TODO Auto-generated method stub
return this.height;
}
}