これが発生する特別な理由はありますか、それともさまざまな理由で発生する可能性がありますか?プログラムが整数を出力することを期待していたので、プログラムが出力している値を出力している理由がわかりません。代わりに私はこれを取得しています:
cycle @ 173a10f cycle @ a62fc3 cycle @ a62fc3 cycle @ a62fc3 cycle @ 530daa cycle @ a62fc3 cycle @ a62fc3 cycle @ 530daa cycle @ a62fc3
これはコードの一部です:(私にはサイクルクラスとスタックとキューのクラスもあります)
import java.io.*;
import java.util.*;
public class PrintQ {
public static void main(String args[]) throws FileNotFoundException {
Scanner inFile = new Scanner(new FileReader("C:\\Users\\Whitney\\Desktop\\QueueIn.txt"));
String job1;
job1=inFile.next();
char char1;
int i=0;
int FirstComma;
int SecondComma;
String charholder;
QueueClass<cycle> list= new QueueClass(100);
QueueClass<Integer> cyclelist= new QueueClass(100);
cycle currentcycle= new cycle();
cycle priorityCycle= new cycle();
cycle Scycle= new cycle();
while(inFile.hasNext()){
switch(job1.charAt(0)) {
case 'q':
{
FirstComma=job1.indexOf(',');
SecondComma=job1.lastIndexOf(',');
currentcycle.jobNumber=Integer.parseInt(job1.substring(FirstComma+1,SecondComma));
currentcycle.cycleNumber=Integer.parseInt(job1.substring(SecondComma+1));
cyclelist.addQueue(currentcycle.cycleNumber);
list.addQueue(currentcycle);
break;
}
case 'p':
{
FirstComma=job1.indexOf(',');
SecondComma=job1.lastIndexOf(',');
priorityCycle.jobNumber=Integer.parseInt(job1.substring(FirstComma+1,SecondComma));
priorityCycle.cycleNumber=Integer.parseInt(job1.substring(SecondComma+1));
cyclelist.addQueue(priorityCycle.cycleNumber);
list.priorityinsert(priorityCycle);
break;
}
case 's':
{
FirstComma=job1.indexOf(',');
SecondComma=job1.lastIndexOf(',');
Scycle.cycleNumber=Integer.parseInt(job1.substring(SecondComma+1));
list.addQueue(Scycle);
cyclelist.addQueue(Scycle.cycleNumber);
break;
}
case 'h':
{
StackClass<Integer> stackjob= new StackClass();
StackClass<Integer> stackcycle= new StackClass();
job1=(String) inFile.next();
while(inFile.hasNext()){
switch(job1.charAt(0)) {
case 'q':
{
FirstComma=job1.indexOf(',');
SecondComma=job1.lastIndexOf(',');
currentcycle.jobNumber=Integer.parseInt(job1.substring(FirstComma+1,SecondComma));
currentcycle.cycleNumber=Integer.parseInt(job1.substring(SecondComma+1));
stackjob.push(currentcycle.jobNumber);
stackcycle.push(currentcycle.cycleNumber);
break;
}
case 'p':
{
FirstComma=job1.indexOf(',');
SecondComma=job1.lastIndexOf(',');
priorityCycle.jobNumber=Integer.parseInt(job1.substring(FirstComma+1,SecondComma));
priorityCycle.cycleNumber=Integer.parseInt(job1.substring(SecondComma+1));
stackjob.push(priorityCycle.jobNumber);
stackcycle.push(priorityCycle.cycleNumber);
break;
}
case 's':
{
FirstComma=job1.indexOf(',');
SecondComma=job1.lastIndexOf(',');
Scycle.cycleNumber=0;
Scycle.cycleNumber=Integer.parseInt(job1.substring(SecondComma+1));
stackjob.push(0);
stackcycle.push(Scycle.cycleNumber);
break;
}
case 'h':
{
continue;
}
}
job1=(String) inFile.next();
}
System.out.println();
System.out.println();
while((stackjob.isEmptyStack()==false) && (stackcycle.isEmptyStack()==false))
{
int printjob;
int printcycle;
Object peek;
printjob=stackjob.peek();
printcycle=stackcycle.peek();
System.out.println("Job Number: "+printjob+" "+"Cycles Remaining: "+printcycle);
stackcycle.pop();
stackjob.pop();
}
continue;
}
}
job1=inFile.next();
}
cycle whilecurrent= new cycle();
while(list.isEmptyQueue()==false)
{
whilecurrent=list.front();
int whilecurrentcycle= cyclelist.front();
list.print();
//System.out.println();
while(whilecurrentcycle != 0)
{
whilecurrentcycle--;
//System.out.println("loop "+whilecurrentcycle);
}
//System.out.println();
//System.out.println(whilecurrent);
cyclelist.deleteQueue();
list.deleteQueue();
}
System.out.println();
list.print();
System.out.println();
}
}