0

我正在运行一个 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();。有任何想法吗?

4

1 回答 1

6

你打了Patient.getNewPt6次电话。

一次在循环外,然后在循环内 5 次。

于 2013-11-03T22:56:13.767 回答