Can someone explain why I can't break the loop? To break the loop Player1Pass or Player2Pass should be false. Also is there a way to break a loop in the middle, for example, Player1Pass = true; BUT let the program finish the whole loop before ending the loop? - By the way I know that the code is not perfect. I have just started my experiences with Java. :)
boolean Player1Pass = true;
boolean Player2Pass = true;
do{
String answer;
Scanner scan = new Scanner (System.in);
System.out.println(pName1 +" would you like to DRAFT another card or PASS?" );
answer = scan.nextLine();
if (answer.equalsIgnoreCase("DRAFT")) {
clsCard cardFace = new clsCard();
System.out.println("Your new card is: " + cardFace);
} else if (answer.equalsIgnoreCase("PASS")) {
Player1Pass = true;
}
System.out.println(pName2 +" would you like to DRAFT another card or PASS?" );
answer = scan.nextLine();
if (answer.equalsIgnoreCase("DRAFT")) {
clsCard cardFace = new clsCard();
System.out.println("Your new card is: " + cardFace);
} else if (answer.equalsIgnoreCase("PASS")) {
Player2Pass = false;
}
}while(Player1Pass || Player2Pass);
}
}
Aucun commentaire:
Enregistrer un commentaire