Answer the question
In order to leave comments, you need to log in
Why isn't the loop ending?
There is enam
public enum OutCome {
BLACKJACK, GAMEOVER, CONTINUE;
}
@Override
public OutCome checkCost(String correction){
if(cost == 21){
System.out.println(blackJack);
return OutCome.BLACKJACK;
}else if(cost > 21){
System.out.println(sadMessage);
return OutCome.GAMEOVER;
}else{
System.out.println(correction + messageForChecker + cost);
return OutCome.CONTINUE;
}
}
OutCome cost = player.checkCost();
Scanner scanner = new Scanner(System.in);
String action = scanner.nextLine();
while ( (!action.equals(enough)) || (cost.equals(OutCome.CONTINUE))){
player.getAnotherCard(deck); //берет карту
player.checkLastCard(); // выводит ее пользователю
cost = player.checkCost(); //переопределяет флаг
// и по новой
System.out.println(message);
action = scanner.nextLine();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question