0
私はRFIDリーダーからRFIDタグを取り出すのに役立つスキャナーにアクセスしています。私はScanner.next();
の周りのループを使ってみましたが、それは何もしません。スキャナーがRFIDリーダーの方法にアクセスすると、そこには永久に留まると私は思います。 RFIDのためのメソッドを終了し、その後、私のループの残りの部分を実行する方法はありますか?残りのループを実行するためにスキャナクラスを終了するにはどうすればよいですか?
//The beginning of the loop
while (!doneYet) {
//Just a set boolean variable that I try to use later
Inter = false;
//A question class that I created, obtains and displays a random question
Test = Work.randomQuestion();
Test.display();
//This is where my problems seem to start, this is the RFID Readers Method.
rfid.addTagGainListener(new TagGainListener() {
public void tagGained(TagGainEvent oe) {
Temp = oe.getValue();
if (Test.getRFIDTag().equals(Temp)) {
System.out.println("You are Correct");
count++;
System.out.println(count);
Inter = true;
System.out.println("out");
/*
* try { System.in.close(); } catch (IOException e) {
* TODO Auto-generated catch block e.printStackTrace();
* }
*/
} else if (!Test.getRFIDTag().equals(Temp)) {
System.out.println("Sorry, you are wrong");
}
return;
}
});
// Before the RFID Opens though, this code is initiated
rfid.openAny();
rfid.waitForAttachment(1000);
sc = new Scanner(System.in);
//This is where I attempted to control the RFID Reader, but this doesn't work
if(!Inter){
sc.next();
}
//How I attempt to end the initial while loop
if(count>10){
doneYet = true;
}
}
ご協力いただきありがとうございます。
このコードがコンパイルされるのは本当に驚きです。あなたの 'count'は' final'に強制されなければなりません。その場合 '++'は許されません。 – Gray