Default Values

Maximum Score: 17 pts (see red text for point breakdown)

In this assignment you will create a class named Participant. Then you will test your class with a tester application we provide. You should read the descriptions of the Participant class methods below, but then open and read the tester application’s main method in detail before you write them. The tester application will help you understand how your methods will be used.

Create a file named Participant.java in your PSA8 directory. Your Participant class will have the following features.

1. Instance Variables (3 pts)

  •  name: The name of the participant; this should be a String.
  •  weight: The weight (lb) of the participant; this should be an int.
  •  height: The height (ft) of the participant; this should be a double.

2. Constructors (3 pts)

  •  Your Participant class should have three constructors.
  •  The first constructor should take in no parameters and set the instance variables to the following default values.

o name: “Joe Schmoe” o weight: 200
o height: 6.0

  •  The second constructor should take in only one parameter, a String to which to set the name. The other two instance variables should be set to default values listed above.
  •  The third constructor should take an appropriate number of parameters to set every instance variable. If weight or height is negative, this constructor should not set the variable to this negative value; instead it should print the following and set the value to the default value listed above: “Incorrect height, height must be positive. Height will be set to default value (6.0).” OR “Incorrect weight, weight must be positive. Weight will be set to default value (200).”

3. Methods (3 pts)
 For every instance variable, you will create a getter and a setter.

o The getter will return the current value of that instance variable.
o The setter will take a parameter and set the instance variable to that value.

Note that if height or weight is negative, you should not update the value. Instead, you should print the following message:
“Incorrect height, height must be positive. Height will not be updated.”
OR

“Incorrect weight, weight must be positive. Weight will not be updated.”

  •  Create a method named toString that takes no parameters and returns a String. The toString output should match the output the tester provides.
  •  Finally, create a getBMI method that calculates and returns the Body Mass Index (BMI) or the participant. The formula for calculating BMI is: ??? = ????h? ×703 h???h?2 Testing the Participant Class: For this assignment, you MUST use our tester application. Incorrect execution of the tester application will result in a potentially low grade.
  •  Download ParticipantTester.java from Blackboard and save it in your PSA8 directory. We highly recommend you review the testing application prior to starting the assignment: it will help you understand what is required of you.
  •  Please note: This tester does NOT test for all possible failure conditions and represents a basic testing method. More extensive automated testing is often applied in industry.

 

  •  The output should EXACTLY match the output shown in PSA8-correct-output.txt (6 pts).
  •  Note: If your implementation is incorrect, the tester will help you determine why. You can use the tester to determine default values, and mistakes you may have made. Comments:

 Comments in the style detailed in the book ARE required. Your code must be properly commented to receive full credit (2 pts).

Do you need help with this assignment or any other? We got you! Place your order and leave the rest to our experts.

Quality Guaranteed

Any Deadline

No Plagiarism