Lab 2 Feedback

Marking scheme:
--------------------

1.6 / 2  -some unit tests failed; TAs, please check for errors

--------------------

TA Comments:
-from Lab 3 onwards, your fields should be private unless they
 appear as public in the API of the class

-your setWeight and setHeight always throw an exception 
 because they validate the fields this.weight and this.height
 instead of the arguments w and h

-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

-one solution for getInterpretationOfBMI is to call this.getBMI()
 on the first line of getInterpretationOfBMI; this will guarantee
 that this.bmi is set correctly

--------------------

Style checker output:

No style errors found by checkstyle; TAs, please check for poorly named
variables, unusual programming constructs, and other style errors.
--------------------

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.E.E.E..E...E.
Time: 0.032
There were 6 failures:

1) testCaseGiven1(tests.TestPerson)
java.lang.IllegalArgumentException

2) testCaseGiven2(tests.TestPerson)
java.lang.IllegalArgumentException

3) testCaseGiven3(tests.TestPerson)
java.lang.IllegalArgumentException

4) testCaseGiven4(tests.TestPerson)
java.lang.IllegalArgumentException

5) testGetBMIInterpretation(tests.TestPerson)
java.lang.IllegalArgumentException

6) testGetBMI(tests.TestPerson)
java.lang.IllegalArgumentException

FAILURES!!!
Tests run: 10,  Failures: 6

--------------------

Your submission:

package implementation;

import java.util.Scanner;
/* Areeba Abidi 214603179
 * Nabil Jaffer 215240575
 */

public class Person {

        public double weight;
        public double height;
        public double bmi;
        public String name;

        Scanner input = new Scanner(System.in);

        /**
         * Value for name is set
         *
         * @param name
         */
        public Person(String name) {
                this.name = name;
        }

        /**
         * The weight of the person is set
         *
         * @param w
         *            weight of the person
         */
        public void setWeight(double w) {
                if (weight <= 0) {
                        throw new IllegalArgumentException();
                }
                this.weight = w;
        }

        /**
         * The height of the person is set
         *
         * @param h
         *            height of the person
         */
        public void setHeight(double h) {
                if (height <= 0) {
                        throw new IllegalArgumentException();
                }
                this.height = h;
        }

        /**
         * returns the value of BMI
         * 
         * @return BMI Body Mass Index
         */
        public double getBMI() {
                double heightSqr = height * height;
                double a = weight / heightSqr;
                double x = Math.round(a * 10);
                bmi = x / 10;
                return bmi;
        }

        /**
         * @return name of the person
         */
        public String getName() {
                return name;
        }

        /**
         * @return weight of the person
         */
        public double getWeight() {
                return weight;
        }

        /**
         * @return height of the person
         */
        public double getHeight() {
                return height;
        }

        /**
         * @return the interpretation done by using BMI of the person
         */
        public String getInterpretationOfBMI() {
                String statement = "";
                if (bmi < 18.5) {
                        statement = "You are under weight";
                }
                if (bmi >= 18.5 && bmi < 25.0) {
                        statement = "normal";
                }
                if (bmi >= 25.0 && bmi < 30.0) {
                        statement = "over weight";
                }
                if (bmi >= 30.0) {
                        statement = "obese";
                }
                return statement;

        }
}