Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import hospital_users.*;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7.  
  8. Patient patient1 = new Patient(1,"Gosho", "Georgiev",
  9. "Man", "example@example.com", false);
  10.  
  11. Doctor doctor1 = new Doctor(2,"Petar","Petrov",
  12. "Man","doctor@wxample.com", 40,"USHNG");
  13.  
  14. Nurse nurse1 = new Nurse(3,"Penka", "Penkova",
  15. "Woman", "penka@yahoo.com", 5);
  16.  
  17.  
  18. ArrayList<User> users = new ArrayList<>();
  19. users.add(patient1);
  20. users.add(doctor1);
  21. users.add(nurse1);
  22. showUserInformation(users);
  23. }
  24.  
  25. public static void showUserInformation(ArrayList<User> users){
  26. for (User i:
  27. users) {
  28. System.out.printf("id: %d\n" +
  29. "Last Name: %s\n" +
  30. "Email: %s\n", i.getId(), i.getLastName(), i.getEmail());
  31. if (i instanceof Doctor){
  32. System.out.printf("\n----- Doctor -----\n" +
  33. "Specialisation: %s\n" +
  34. "Years Experience: %d", ((Doctor) i).getSpecialisation(), ((Doctor) i).getYearsOfExperience());
  35. }else if(i instanceof Nurse){
  36. System.out.printf("\n~~~~~ Nurse ~~~~~\n" +
  37. "Nurse ID: %d\n" +
  38. "Gender: %s", ((Nurse) i).getNurseId(), i.getGender());
  39. }
  40. }
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement