Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hospital_users.*;
- import java.util.ArrayList;
- public class Main {
- public static void main(String[] args) {
- Patient patient1 = new Patient(1,"Gosho", "Georgiev",
- "Man", "example@example.com", false);
- Doctor doctor1 = new Doctor(2,"Petar","Petrov",
- "Man","doctor@wxample.com", 40,"USHNG");
- Nurse nurse1 = new Nurse(3,"Penka", "Penkova",
- "Woman", "penka@yahoo.com", 5);
- ArrayList<User> users = new ArrayList<>();
- users.add(patient1);
- users.add(doctor1);
- users.add(nurse1);
- showUserInformation(users);
- }
- public static void showUserInformation(ArrayList<User> users){
- for (User i:
- users) {
- System.out.printf("id: %d\n" +
- "Last Name: %s\n" +
- "Email: %s\n", i.getId(), i.getLastName(), i.getEmail());
- if (i instanceof Doctor){
- System.out.printf("\n----- Doctor -----\n" +
- "Specialisation: %s\n" +
- "Years Experience: %d", ((Doctor) i).getSpecialisation(), ((Doctor) i).getYearsOfExperience());
- }else if(i instanceof Nurse){
- System.out.printf("\n~~~~~ Nurse ~~~~~\n" +
- "Nurse ID: %d\n" +
- "Gender: %s", ((Nurse) i).getNurseId(), i.getGender());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement