Guest User

Untitled

a guest
Jan 21st, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. public class TestPerson {
  2.  
  3. public static void main(String[] args) {
  4. Person person = new Person("John Doe", "123 Somewhere", "415-555-1212", "johndoe@somewhere.com");
  5. Person student = new Student("Mary Jane", "555 School Street", "650-555-1212", "mj@abc.com", "junior");
  6. Person employee = new Employee("Tom Jones", "777 B Street", "40-88-889-999", "tj@xyz.com");
  7. Person faculty = new Faculty("Jill Johnson", "999 Park Ave", "92-52-22-3-333", "jj@abcxyz.com");
  8. Person staff = new Staff("Jack Box", "21 Jump Street", "707-21-2112", "jib@jack.com");
  9.  
  10. System.out.println(person.toString() + "n");
  11. System.out.println(student.toString() + "n");
  12. System.out.println(employee.toString() + "n");
  13. System.out.println(faculty.toString() + "n");
  14. System.out.println(staff.toString() + "n");
  15. }
  16. }
  17.  
  18. public class TestPerson {
  19.  
  20. public static void main(String[] args) {
  21. Person person = new Person("John Doe", "123 Somewhere", "415-555-1212", "johndoe@somewhere.com");
  22. Person student = new Student("Mary Jane", "555 School Street", "650-555-1212", "mj@abc.com", "junior");
  23. Person employee = new Employee("Tom Jones", "777 B Street", "40-88-889-999", "tj@xyz.com");
  24. Person faculty = new Faculty("Jill Johnson", "999 Park Ave", "92-52-22-3-333", "jj@abcxyz.com");
  25. Person staff = new Staff("Jack Box", "21 Jump Street", "707-21-2112", "jib@jack.com");
  26.  
  27. System.out.println(person.toString() + "n");
  28. System.out.println(student.toString() + "n");
  29. System.out.println(employee.toString() + "n");
  30. System.out.println(faculty.toString() + "n");
  31. System.out.println(staff.toString() + "n");
  32. }
  33. }
  34.  
  35. public class Person {
  36.  
  37. private String name;
  38. private String address;
  39. private String phone_number;
  40. private String email_address;
  41.  
  42. public Person() {
  43. }
  44.  
  45. public Person(String newName, String newAddress, String newPhone_number, String newEmail){
  46. name = newName;
  47. address = newAddress;
  48. phone_number = newPhone_number;
  49. email_address = newEmail;
  50. }
  51.  
  52. public void setName(String newName){
  53. name = newName;
  54. }
  55.  
  56. public String getName(){
  57. return name;
  58. }
  59.  
  60. public void setAddress(String newAddress){
  61. address = newAddress;
  62. }
  63.  
  64. public String getAddress(){
  65. return address;
  66. }
  67.  
  68. public void setPhone(String newPhone_number){
  69. phone_number = newPhone_number;
  70. }
  71.  
  72. public String getPhone(){
  73. return phone_number;
  74. }
  75.  
  76. public void setEmail(String newEmail){
  77. email_address = newEmail;
  78. }
  79.  
  80. public String getEmail(){
  81. return email_address;
  82. }
  83.  
  84. public String toString(){
  85. return "Name :"+getName();
  86. }
  87.  
  88. }
  89.  
  90. public class Student extends Person {
  91.  
  92. public final String class_status;
  93.  
  94. public Student(String name, String address, int phone, String email, String classStatus) {
  95. super(name, address, phone, email);
  96. class_status = classStatus;
  97. }
  98. public String toString(){
  99. return "Student Status: " + super.getName();
  100. }
  101.  
  102. }
  103.  
  104. import java.util.Date;
  105. public class Employee extends Person{
  106.  
  107. private String office;
  108. private double salary;
  109. private Date hire;
  110.  
  111. public Employee() {
  112. }
  113.  
  114. public Employee(String name, String address, int phone, String email){
  115. super(name, address, phone, email);
  116. }
  117.  
  118. public Employee(String office, double salary, Date hire){
  119. this.office = office;
  120. this.salary = salary;
  121. this.hire = hire;
  122. }
  123.  
  124. public void setOffice(String office){
  125. this.office = office;
  126. }
  127.  
  128. public String getOffice(){
  129. return this.office;
  130. }
  131.  
  132. public void setSalary(double salary){
  133. this.salary = salary;
  134. }
  135.  
  136. public double getSalary(){
  137. return this.salary;
  138. }
  139.  
  140. public void setHire(Date hire){
  141. this.hire = hire;
  142. }
  143.  
  144. public Date getHire(){
  145. return this.hire;
  146. }
  147.  
  148. public String toString(){
  149. return "Office " + super.getName();
  150. }
  151. }
  152.  
  153. public class Faculty extends Employee {
  154. private String officeHours;
  155. private int rank;
  156.  
  157. public Faculty(String name, String address, int phone, String email) {
  158. super(name, address, phone, email);
  159. }
  160.  
  161. public String toString(){
  162. return "Office " + super.getOffice();
  163. }
  164. }
  165.  
  166. public class Staff extends Employee {
  167. private String title;
  168.  
  169. public Staff(String name, String address, int phone, String email) {
  170. super(name, address, phone, email);
  171. }
  172.  
  173. public Staff(String title){
  174. this.title = title;
  175. }
  176.  
  177. public void setTitle(String title){
  178. this.title = title;
  179. }
  180. public String getTitle(){
  181. return this.title;
  182. }
  183.  
  184. public String toString(){
  185. return "Title :" + super.getName();
  186. }
  187. }
  188.  
  189. Student(String name, String addr, String phone, String email) {
  190. ....
  191. }
  192.  
  193. public String toString() {
  194. return this.name + "n" + this.addr + "n" + this.phone + "n" + this.email;
  195.  
  196. }
  197.  
  198. public Student(String name, String address, int phone, String email, String classStatus)
Add Comment
Please, Sign In to add comment