HI ,I am new in Java and i have trablle creating array of objects .This are my files,and I need to create array of objects patients
thank you in advance for your help
import java.util.*;
public class MainPatient {
public static void main(String[] args) {
int choice=0;
Scanner input=new Scanner(System.in);
Patient patientObj=new Patient();
while(choice!=4){
System.out.println("1.Add new patient");
System.out.println("2.Display by priority");
System.out.println("3.Display by name(sorted by last name)");
System.out.println("4.Exit");
System.out.print("Enter your choise: ");
choice=input.nextInt();
patientObj.makeChoice(choice);
}
}
}
--
import java.util.*;
public class Patient {
Scanner input=new Scanner(System.in);
public String fName;
public String lName;
public int priority;
public Patient(){
this.fName="";
this.lName="";
this.priority=0;
}
public Patient(String fname,String sname,int priority){
this.fName=fname;
this.lName=sname;
this.priority=priority;
}
public void setfName(String name){
this.fName=name;
}
public String getfName(){
return fName;
}
public void setlName(String name){
this.lName=name;
}
public String getlName(){
return lName;
}
public void setPriority(int priority){
this.priority= priority;
}
public int getPriority(){
return priority;
}
public void setPatient(){
System.out.print("Enter First Name: ");
setfName(input.next());
System.out.print("Enter Last Name: ");
setlName(input.next());
System.out.print("Enter Priority: ");
setPriority(input.nextInt());
}
public void makeChoice(int choice){
switch(choice)
{
case 1:setPatient();
break;
case 2:System.out.println("Display priority");
break;
case 3:System.out.println("display by name");
break;
case 4:System.out.println("exit");
break;
default : System.out.println("wrong choice");
break;
}
}
}