-4
私は、医者の配列で患者を表現するためのJavaプログラムを作成しています。それはデータ構造のノードを追加することができますが、私がそれを印刷しようとすると、私はそれを爆破します。ここにメソッドがありますJavaキューは、forループ内の最後の要素のみを出力します。
static boolean [] openflag = new boolean[6];
static queue [] Clinic = new queue[6];
static String [] Doctor = {"Doctor 1", Doctor 2", "Doctor 3","Doctor
4","Doctor 5","Doctor 6"};
final static String HEADING = "The clinic moniter of Dylan Rychlik";
static int MAX = 6;
public static void Listpaitents()
{
int queuechoice;
JOptionPane.showMessageDialog(null, "Which doctor would you like to print?");
String InputString = JOptionPane.showInputDialog(null,Doctor, HEADING,
JOptionPane.QUESTION_MESSAGE);
queuechoice = Integer.parseInt(InputString);
if (openflag[queuechoice -1 ] == false){
JOptionPane.showMessageDialog(null, "Sorry, that doctor is notaviable");
}
else{
Paitent[] array = Clinic[queuechoice -1].toArray();
//int size = Clinic[queuechoice -1].getSize();
int limit = Clinic[queuechoice -1].getSize();
//System.out.println(limit);
int x; String out = " Members of the list are: \n";
// boolean exit = false;
for(x = 1; x <= limit; x++) {
out += array[x-1].Print() + "\n";
// System.out.println(array[x-1] + "\n");
}
JOptionPane.showMessageDialog(null,out);
}
}
ここはキュークラスのtoarray()メソッドです。
public static Paitent[] toArray()
{
int x = Length;
Paitent[] Array = new Paitent[Length];
queuenode Current = rear;
for (x = Length; ((Current != null) && (x >= 1));x--)
{
Array[x-1] = new Paitent();
Array[x-1].update(Current.info);
Current = Current.next;
}
return Array;
}
そして最後に、ここでpaitentクラス
public class Paitent {
protected static String name;
protected static String telephone;
protected static int ID;
//Creates a constructor for a paitent object
public void paitent()
{
name = "";
telephone = " ";
ID = 0;
}
//updates the country object
public void update(Paitent thisThing)
{
name = thisThing.name;
telephone = thisThing.telephone;
ID = thisThing.ID;
}
//asks for user input for country objects
public void input(int i)
{
String PatronHeading = "Country Data Entry";
String entername;
int enterID;
String enterphone;
entername = JOptionPane.showInputDialog(null, "Please Enter the name of
paitent #" + i +": ", PatronHeading, JOptionPane.QUESTION_MESSAGE);
enterphone = JOptionPane.showInputDialog(null, "Please Enter the telephone
number for paitent #" + i +": ", PatronHeading,
JOptionPane.QUESTION_MESSAGE);
String PNumberString = JOptionPane.showInputDialog(null, "Please Enter the
ID for paitent #" + i +": ", PatronHeading, JOptionPane.QUESTION_MESSAGE);
enterID = Integer.parseInt(PNumberString);
name = entername;
telephone = enterphone;
ID = enterID;
}
//prints the results
public String Print()
{
String outputString;
outputString = "Paitent: " + "-" + name + "\n" + " Telephone number " +
telephone + " ID " + ID;
return outputString;
}
//gets and sets the PCI in order to sort them
}
すべてのヘルプですか?それを修正するためにいくつかの戦術を試してみましたが、何も動作していないようです。コードがたくさんあるので、完全なコードが必要な場合はお知らせください!
'それはme'上に吹くと'をクリーンアップ何も働いていないようだ」というのは良い説明ではない。 [mcve]を作成します。 – Idos
この質問を読むのには2つの大きな問題があります。あなたのコードのフォーマットは最適ではありません。さらに、 'Java命名規則 'に従うと、混乱した書式が追加されます。 – SomeJavaGuy
提供したコードはコンパイルされません。最初のコンパイルエラーは次のとおりです: '{" Doctor 1 "、Doctor 2"、 "Doctor 3"、 "Doctor 4"、 "Doctor 5"、 "Doctor 6"}; ' – Jens