Hello everyone, sorry i could not answer back right away, and thank you for your answers
I just changed the conditionals, using switch and char variables in order to campare , win = w, lose = l, continue = c.
* BUT It returns WRONG answers , when it is NOT a win or a lose MEANS, when it is continue.
* i would like you take a look at the second time when generate the numbers, i use different variable "ddado1" and "ddado2"
because if i continue with the originals "dado1" and "dado2" i got a error, saying that dado1 and dado2 are already define in main(java.lang.String[])
ANY HELP PLEASE.
import java.util.Scanner;
import java.lang.String;
import java.util.Random;
public class Craps
{
public static void main (
String[] args)
{
Scanner keyboard = new Scanner(System.in);
String answer;
char stat = ' ';
char gamestat = ' ';
int roll2 = 0;
do
{
Die dado1 = new Die();//store roll1 in a new var1
Die dado2 = new Die();//store roll2 in a new var2
// my point V iqual the sum of the two rolls
int thePoint = (dado1.getRoll() + dado2.getRoll());
System.out.println();
System.out.print("You rolled "+thePoint+" . ");
switch (thePoint)
{
case 7:
case 11:
System.out.println("You Win !");// winner
stat = 'w';
gamestat = stat;
break;
case 2:
case 3:
case 12:
System.out.println("You Lose !");// loser
stat = 'l';
gamestat = stat;
break;
default:
stat = 'c';
gamestat = stat;
break;
}
while ( gamestat == 'c' )
{
Die ddado1 = new Die();//store roll1 in a new var1
Die ddado2 = new Die();//store roll2 in a new var2
roll2 = (ddado1.getRoll() + ddado2.getRoll());
if (roll2 == thePoint){
gamestat = 'w';
System.out.println("You Winnnnn !");
}else if (roll2 == 7){
gamestat = 'l';
System.out.println("You Looooose !");
}
}
*******************************************************
// random numbers class
mport java.util.Random;
public class Die
{
private int tiro;
private final static Random random = new Random();
public Die()
{
tiro =random.nextInt(6) + 1;
}
public int getRoll()
{
return tiro;
}
}