Код: Выделить всё
public class CasinoSlot{
public void play(){
int coins=(int)(Math.random()*20+5);
System.out.println("You have "+coins+" coins.");
int bet=(int)(Math.random()*4+0);
System.out.println("You bet "+bet+" coins.");
if (bet==0){
System.out.println("Please try again.");
}
else{
int rem=coins-bet;
if (bet>0){
System.out.println("You have "+rem+" coins remaining.");
}
int d1=(int)(Math.random()*6+1);
int d2=(int)(Math.random()*6+1);
int d3=(int)(Math.random()*6+1);
int same=(10*bet), rsame=(same+rem);
int same2=(7*bet), rsame2=(same2+rem);
int oddeven=(5*bet), roddeven=(oddeven+rem);
int lose=(-1*bet), rlose=(lose+rem);
System.out.println("You rolled: "+d1+", "+d2+", "+d3);
if(d1==d2 && d2==d3){
System.out.println("You win "+same+" coins. You now have "+rsame+" coins remaining.");
}
else if(d1==d2 || d2==d3 || d1==d3){
System.out.println("You win "+same2+" coins. You now have "+rsame2+" coins remaining.");
}
else if((d1%2==0 && d2%2==0 && d3%2==0) || (d1%2!=0) && (d2%2!=0) && (d3%2!=0)){
System.out.println("You win "+oddeven+" coins. You now have "+roddeven+" coins remaining.");
}
else{
System.out.print("You lose "+lose+" coins. You now have "+rlose+" coins.");
}
}
}
}
Мобильная версия