我正在运行一个for循环,它接受了6名患者,当它应该只接受5.我不知道为什么。
患者类:
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();
}
编辑我意识到我不需要getNewPt
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;
}
患者管理课程:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class PatientManagementSystem
{
static BufferedReader stdin = new BufferedReader(new InputStreamReader(
System.in));
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();
}
}
这不是来自Patient.getOption();
。有什么想法吗?
答案 0 :(得分:6)
你打电话Patient.getNewPt
6次。
一旦进入循环,然后在循环内进行5次。