This is the 2nd out of 3 classes in my code and I'm not sure if it will work although Im not sure why Its on an infinite loop? I'm trying to make this game work so everytime a bet is either won or lost it affects my game so for one the pot is zero the game will end. It doesnt seem to be working although, any suggestions?
import java
.util.Scanner;
public class Game {
public int potAmount = 50;
public int betAmount= 0;
private Scanner input = new Scanner (System.in);
public void displayPot(){
System.out.println("Your current pot is "+potAmount+"");
}
public void getbetamountfromuser(){
System.out.println("Enter your bet amount:");
betAmount = input.nextInt();
potAmount= potAmount - betAmount;
}
public void playgame(){
while( potAmount > 0) {
Die Die1 = new Die();
Die Die2 = new Die();
Die Die3 = new Die();
Die1.rollDice();
Die2.rollDice();
Die3.rollDice();
Die1.Getdie();
Die2.Getdie();
Die3.Getdie();
System.out.println("Your die are: ");
Die1.displayDice();
System.out.print( " and ");
Die2.displayDice();
System.out.print( " and ");
Die3.displayDice();
int Totaldice=Die1.Getdie()+Die2.Getdie()+Die3.Getdie();
if (Totaldice>=12){
System.out.print("You WIN...your bet back");
}
else if (Totaldice<12){
System.out.print("You LOSE....your bet ");
}
if (Die1==Die2 ){
System.out.print("You WIN....double your bet");
if (Die2==Die3 ){
System.out.print("You WIN....double your bet");
if (Die1==Die3 ){
System.out.print("You WIN....double your bet");
}
}
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire