Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DoctorTest
- {
- public static void main()
- {
- String name, specialty;
- double officeFee;
- boolean isEqual;
- System.out.println("This program tests inheritance between a Person and Doctor classes");
- System.out.println("Doctor No - Using default constructor...");
- Doctor d1 = new Doctor();
- System.out.println("Verify that name: No name yet., Office Fees: $150.00, and Specialty: None given.");
- d1.printInfo();
- System.out.println("===============================");
- System.out.println("Doctor Jekyll - Using constructor with no office fees ...");
- Doctor d2 = new Doctor("Jekyll", "Psychologist");
- System.out.println("\nVerify that name: Jekyll, Office Fees: $150.00, and Specialty: Psychologist");
- d2.printInfo();
- System.out.println("===============================");
- System.out.println("Doctor Holiday - Constructor with name, office fee, and specialty");
- Doctor d3 = new Doctor("Holiday", "General Practitioner", 200.99);
- System.out.println("\nVerify that name: Holiday, Office Fees: $200.99, and Specialty General Practitioner");
- d3.printInfo();
- System.out.println("===============================");
- System.out.println("Testing get method getName() for Dr. Holiday ...");
- name = d3.getName();
- System.out.println("Name : " + name);
- System.out.println("===============================");
- System.out.println("Test getOfficeFee() method for Dr. Holiday ...");
- System.out.println("Verify that his office fees are $200.99");
- officeFee = d3.getOfficeFee();
- System.out.println("Office fees: " + officeFee);
- System.out.println("===============================");
- System.out.println("Test getSpecialty() method for Dr. Holiday ...");
- System.out.println("Verify that he is a General Practitioner");
- specialty = d3.getSpecialty();
- System.out.println("Specialty: " + specialty);
- System.out.println("===============================");
- System.out.println("Testing set methods for Dr No");
- System.out.println("Set setOfficeFee() to 1234.56 and setSpecialty() to Laser Surgery ...");
- System.out.println("Default parameter values before set:");
- d1.printInfo();
- System.out.println("Verify that after set: Name: No name yet., Office fees: $1234.56, and Specialty: Laser Surgery");
- officeFee = 1234.56;
- specialty = "Laser Surgery";
- d1.setOfficeFee(officeFee);
- d1.setSpecialty(specialty);
- d1.printInfo();
- System.out.println("===============================");
- System.out.println("Using getOfficeFee() method for Dr. No ...");
- System.out.println("Verify that Office fees: $1234.65, and Specialty: Laser Surgery");
- System.out.println("Office Fee: " + d1.getOfficeFee() + "\nSpecialty: " + d1.getSpecialty());
- System.out.println("===============================");
- System.out.println("Testing equals() method - test 1...");
- System.out.println("First Doctor No's parameters values:");
- d1.printInfo();
- System.out.println("");
- System.out.println("Create Doctor Yes object (overloaded Cnstructor) that has the same specialty as Dr. No ...");
- Doctor d4 = new Doctor("Yes", "Laser Surgery", 950.00);
- System.out.println("Doctor Yes's values using printInfo():");
- d4.printInfo();
- System.out.println("Test equality - Verify that the result is false");
- isEqual = d4.equals(d1);
- System.out.println("Equality test result is: " + isEqual);
- System.out.println("===============================");
- System.out.println("Testing equals() method - test 2 ...");
- System.out.println("Change office fee of Dr. Yes to be equal to those of Dr. No");
- d4.setOfficeFee(d1.getOfficeFee());
- System.out.println("First Doctor's parameter values:");
- d1.printInfo();
- System.out.println("Second Doctor's parameter values:");
- d4.printInfo();
- System.out.println("Test equality - Verify that the result is false");
- isEqual = d4.equals(d1);
- System.out.println("Equality test result is: " + isEqual);
- System.out.println("===============================");
- System.out.println("Testing equals() method - test 3 ...");
- System.out.println("Comparing Dr. Jekyll with himself");
- System.out.println("First Doctor's parameter values:");
- d2.printInfo();
- System.out.println("");
- System.out.println("Second Doctor's parameter values:");
- d2.printInfo();
- System.out.println("Test equality - Verify that the result is true");
- isEqual = d2.equals(d2);
- System.out.println("Equality test result is: " + isEqual);
- System.out.println("===============================");
- System.out.println("\nEnd of program. Good Bye!!");
- System.out.println("TESSSSSSSSSSSST");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement