我想知道如何编写代码来做到这一点,让我们说如果 newSumDealer > newSumPlayer,然后经销商获胜。到目前为止,我只让玩家获胜或平局。我是 java 新手,所以请在这里帮帮我.. 给我一个线索左右,我会试着弄清楚。
编辑:
//output
System.out.println( "Player has " +number1+ " , " +number2+ " for a hand worth of ");
if ( sumPlayer <= 10)
System.out.println( +sumPlayer+ " .");
else if (sumPlayer > 10) {
sumPlayer = sumPlayer - 10;
System.out.println( sumPlayer - 10);
}
System.out.println( "Dealer has " +number3+ " , " +number4+ " for a hand worth of ");
if ( sumDealer <= 10 )
System.out.println( +sumDealer+ " .");
else if ( sumDealer > 10 ) {
sumDealer = sumDealer - 10;
System.out.println( sumDealer - 10);
}
//who wins
if(sumPlayer == sumDealer) {
System.out.println("It's a tie!");
} else if (sumPlayer > sumDealer) {
System.out.println("Player wins!");
} else {
System.out.println("Dealer wins!");
}
}
}