Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class DoctorTest
  3. {
  4. public static void main()
  5. {
  6. String name, specialty;
  7. double officeFee;
  8. boolean isEqual;
  9.  
  10. System.out.println("This program tests inheritance between a Person and Doctor classes");
  11. System.out.println("Doctor No - Using default constructor...");
  12. Doctor d1 = new Doctor();
  13. System.out.println("Verify that name: No name yet., Office Fees: $150.00, and Specialty: None given.");
  14.  
  15. d1.printInfo();
  16.  
  17. System.out.println("===============================");
  18. System.out.println("Doctor Jekyll - Using constructor with no office fees ...");
  19. Doctor d2 = new Doctor("Jekyll", "Psychologist");
  20. System.out.println("\nVerify that name: Jekyll, Office Fees: $150.00, and Specialty: Psychologist");
  21.  
  22. d2.printInfo();
  23.  
  24. System.out.println("===============================");
  25. System.out.println("Doctor Holiday - Constructor with name, office fee, and specialty");
  26. Doctor d3 = new Doctor("Holiday", "General Practitioner", 200.99);
  27. System.out.println("\nVerify that name: Holiday, Office Fees: $200.99, and Specialty General Practitioner");
  28.  
  29. d3.printInfo();
  30.  
  31. System.out.println("===============================");
  32. System.out.println("Testing get method getName() for Dr. Holiday ...");
  33. name = d3.getName();
  34. System.out.println("Name : " + name);
  35.  
  36. System.out.println("===============================");
  37. System.out.println("Test getOfficeFee() method for Dr. Holiday ...");
  38. System.out.println("Verify that his office fees are $200.99");
  39. officeFee = d3.getOfficeFee();
  40. System.out.println("Office fees: " + officeFee);
  41.  
  42. System.out.println("===============================");
  43. System.out.println("Test getSpecialty() method for Dr. Holiday ...");
  44. System.out.println("Verify that he is a General Practitioner");
  45. specialty = d3.getSpecialty();
  46. System.out.println("Specialty: " + specialty);
  47.  
  48. System.out.println("===============================");
  49. System.out.println("Testing set methods for Dr No");
  50. System.out.println("Set setOfficeFee() to 1234.56 and setSpecialty() to Laser Surgery ...");
  51. System.out.println("Default parameter values before set:");
  52.  
  53. d1.printInfo();
  54.  
  55. System.out.println("Verify that after set: Name: No name yet., Office fees: $1234.56, and Specialty: Laser Surgery");
  56. officeFee = 1234.56;
  57. specialty = "Laser Surgery";
  58. d1.setOfficeFee(officeFee);
  59. d1.setSpecialty(specialty);
  60.  
  61. d1.printInfo();
  62.  
  63. System.out.println("===============================");
  64. System.out.println("Using getOfficeFee() method for Dr. No ...");
  65. System.out.println("Verify that Office fees: $1234.65, and Specialty: Laser Surgery");
  66. System.out.println("Office Fee: " + d1.getOfficeFee() + "\nSpecialty: " + d1.getSpecialty());
  67.  
  68. System.out.println("===============================");
  69. System.out.println("Testing equals() method - test 1...");
  70. System.out.println("First Doctor No's parameters values:");
  71.  
  72. d1.printInfo();
  73.  
  74. System.out.println("");
  75. System.out.println("Create Doctor Yes object (overloaded Cnstructor) that has the same specialty as Dr. No ...");
  76. Doctor d4 = new Doctor("Yes", "Laser Surgery", 950.00);
  77. System.out.println("Doctor Yes's values using printInfo():");
  78.  
  79. d4.printInfo();
  80.  
  81. System.out.println("Test equality - Verify that the result is false");
  82. isEqual = d4.equals(d1);
  83. System.out.println("Equality test result is: " + isEqual);
  84.  
  85. System.out.println("===============================");
  86. System.out.println("Testing equals() method - test 2 ...");
  87. System.out.println("Change office fee of Dr. Yes to be equal to those of Dr. No");
  88. d4.setOfficeFee(d1.getOfficeFee());
  89. System.out.println("First Doctor's parameter values:");
  90.  
  91. d1.printInfo();
  92.  
  93. System.out.println("Second Doctor's parameter values:");
  94.  
  95. d4.printInfo();
  96.  
  97. System.out.println("Test equality - Verify that the result is false");
  98. isEqual = d4.equals(d1);
  99. System.out.println("Equality test result is: " + isEqual);
  100.  
  101. System.out.println("===============================");
  102. System.out.println("Testing equals() method - test 3 ...");
  103. System.out.println("Comparing Dr. Jekyll with himself");
  104. System.out.println("First Doctor's parameter values:");
  105.  
  106. d2.printInfo();
  107.  
  108. System.out.println("");
  109. System.out.println("Second Doctor's parameter values:");
  110.  
  111. d2.printInfo();
  112.  
  113. System.out.println("Test equality - Verify that the result is true");
  114. isEqual = d2.equals(d2);
  115. System.out.println("Equality test result is: " + isEqual);
  116.  
  117. System.out.println("===============================");
  118. System.out.println("\nEnd of program. Good Bye!!");
  119. System.out.println("TESSSSSSSSSSSST");
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement