I have created a class, constructors and accessors. I am wondering if there is an easier way to do this?
I have a Patient class:
public Patient(final String ptNo, final String ptName,
final String procDate, final int procType, final String injury,
final String drName) throws IOException
{
Patient.ptNo = getPtNo();
Patient.ptName = getPtName();
Patient.procDate = getProcDate();
Patient.procType = getProcType();
Patient.injury = getPtNotes();
Patient.drName = getDrName();
}
And a getter for this class.
public static Patient getNewPt(String ptNo, String ptName,
String procDate, int procType, String
injury, String drName) throws IOException
{
Patient newPt = new Patient (ptNo,
ptName, procDate, procType, injury, drName);
return newPt;
}
So I could create new patients:
public static void main(String[] args) throws IOException
{
Patient.getNewPt(null, null, null, 0, null, null);
// creating an array of 5 patients
Patient patients[] = new Patient[5];
int i = 0;
for (i = 0; i < 5; i++)
{
patients[i] = Patient.getNewPt(null, null, null, i, null, null);
}
Patient.getOption();
}
And also create new patients through a menu option:
public static String getOption() throws IOException
{
System.out.println("bla bla");
option = stdin.readLine();
switch (option)
{
case ("N"):
Patient newPt = new Patient (ptNo,
ptName, procDate, procType, injury, drName);
break;// and so on
I asked another question For loop accepting an extra array member and then realised something that I thought might make a helpful Q&A for newcomers like myself.