ParticipantTester.java

ParticipantTester.java - public class ParticipantTester...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
public class ParticipantTester { public static void main(String [] args) { boolean passed = true; System.out.println("Creating a default participant\n"); Participant participant = new Participant(); System.out.println("Testing correct default name using the getName method\n"); if(participant.getName().equals("Joe Bob")) System.out.println("\t[Correct]\n"); else { passed = false; System.out.println("\t["+participant.getName() + " is incorrect, the default name should be Joe Bob]\n"); } System.out.println("Testing correct default weight using the getWeight method\n"); if(participant.getWeight() == 1) System.out.println("\t[Correct]\n"); else { passed = false; System.out.println("\t["+participant.getWeight() +" is incorrect, the default weight should be 1]\n"); } System.out.println("Testing correct default height using the getHeight method\n"); if(participant.getHeight() == 1.0) System.out.println("\t[Correct]\n"); else { passed = false; System.out.println("\t["+participant.getHeight() +" is incorrect, the default height should be 1.0]\n"); } System.out.println("Testing the getBMI method on the first participant\n"); if(participant.getBMI() == 703.0) System.out.println("\t[Correct]\n"); else { passed = false; System.out.println("\t["+participant.getBMI() +" is incorrect, the default BMI should be 703.0]\n"); } System.out.println("Testing each set method using a default participant\n"); participant.setName("Sally Jane"); System.out.println("Testing setName method using the getName method\n"); if(participant.getName().equals("Sally Jane")) System.out.println("\t[Correct]\n"); else { passed = false; System.out.println("\t["+participant.getName() + " is incorrect, the updated name should be Sally Jane]\n"); } participant.setWeight(100); System.out.println("Testing setWeight method using the getWeight method\n"); if(participant.getWeight() == 100) System.out.println("\t[Correct]\n"); else { passed = false; System.out.println("\t["+participant.getWeight() +" is incorrect, the updated weight should be 100]\n");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

ParticipantTester.java - public class ParticipantTester...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online