Untitled
unknown
plain_text
2 years ago
2.7 kB
6
Indexable
public static boolean registerVisit(ArrayList<Patient>patientList, ArrayList<Visitor> visitorList) { boolean patientfound = false; boolean isdischarged=true; int num=0; int Pcount=0; int Vcount=0; boolean cont=true; while (Vcount<=4) { String Pname =Helper.readString("enter patient name: "); String Pward =Helper.readString("enter patient ward : "); for (int i=0;i<patientList.size();i++) { if (Pname.equalsIgnoreCase(patientList.get(i).getName())&& Pward.equals(patientList.get(i).getWard())) { patientfound=true; if (cont==false) { break; } if ( patientList.get(i).getDatedischarged().isEmpty()==false) { isdischarged=true; } if (patientfound==false) { System.out.println("name or ward is invalid "); System.out.println("please try again ! "); } if (patientfound==true && cont==true) { String nric4= Helper.readString("enter visitor 4 digit nric: "); String name =Helper.readString("enter visitor name: "); String number =Helper.readString("Enter contact number: "); String date_of_visit =Helper.readString("enter date of visit : "); Vcount=patientList.get(i).getVisitorcount()+1; Pcount=patientList.get(i).getVisitorcount()+1; patientList.get(i).setVisitorcount(Pcount); Visitor newvisitor =(new Visitor(nric4,name,Pname,Pward,number,date_of_visit)); newvisitor.display(); visitorList.add(new Visitor(newvisitor.getNric4(),newvisitor.getName(),newvisitor.getPname(),newvisitor.getPward(),newvisitor.getNumber(),newvisitor.getDate_of_visit())); } // cont=Helper.readBoolean("Add another visitor: "); // if (cont==false) { // break; // } if (4-(patientList.get(i).getVisitorcount())==0) { System.out.println("*** no additional visitor allowed ***"); } else if (4-patientList.get(i).getVisitorcount()>0) { System.out.println("*** please proceed to ward *** "); int extra =4-Pcount; System.out.println("*** only "+extra+" visitors allowed *** "); num=num+Pcount; patientList.get(i).setVisitorcount(num); if (Pcount> extra) { System.out.println("*** visitor exceeded ***"); } } else if (4-patientList.get(i).getVisitorcount()<0) { System.out.println("***visitor exceeded *** "); } else if (isdischarged==true) { System.out.println("***patient has already been discharged***"); } else if (patientList.get(i)==null ){ System.out.println("***no such patient in ward ***"); } } } } return patientfound; }
Editor is loading...