Code:
Package net.day06027;
Import java.util.Scanner;
Import java.util.regex.Pattern;
/ **
*
* Item Description: simulated gambling: random number generating simulated three dice 1 to 6, the player bets guess the size
* created: Administrator
* created: June 28, 2019 8:15:44 aM
* @version
* /
public class DUBO {
static Scanner the INPUT = new new Scanner (System.in);
public static void main (String [] args ) {
System.out.println ( "Welcome to the Casino Royale ************* *************!" );
boolean Flag = to true ;
do{
// negotiable chips
System.out.println ( "Please enter your chips to redeem (million):" );
String MyMoney = input.next ();
// regular expression to solve for the possible non-numeric input letters
Pattern = of Pattern.compile the pattern1 ( "[0-9] *" );
Boolean scanned using the ISNUM = pattern1.matcher (MyMoney) .matches ();
// determination condition
IF (== scanned using the ISNUM to false ) {
System.out.println ( "your is not a number, please re-enter "! );
// enter the correct entered the game
} the else IF (Integer.parseInt (MyMoney)> = 50) {
Int myMoney1 = Integer.parseInt (MyMoney);
System.out.println ( "Please confirm whether or not to start the game (the y-/ the n-)!" );
Boolean FLAG1 = false ;
String sc = input.next ();
// give the player a chance contrite
do {
IF (sc.equals ( "Y" )) {
// random () method of generating three random numbers 1 to 6, and calculates the number of three and
int a = ( int ) ( math.random () * +. 1. 6 );
int B = ( int ) (Math.random () * +. 1. 6);
Int c = ( int ) (Math.random () * 6 + 1 );
int SUM = A + b + c;
// player bets, and provides betting range
System.out.print ( "Make your choice pressure and big / small (large / small) !: " );
String the Choose = input.next ();
System.out.print ( " you bet chips (chips not less than 10): " );
boolean FLAG2;
int Chip = input.nextInt ();
do {
// In Flag to false =;
IF (Chip <10 || Chip> myMoney1) {
FLAG2 = to true ;
System.out.print ( "you bet chips chips is illegal, please re-bet (chips not less than 10):" );
Chip = the INPUT .nextInt ();
// BREAK;
} the else {
System.out.println ( "You bet chips is:" + Chip);
String the Result = SUM> 10 "big":? "small" ;
IF (the Choose. equals (result)) {
System.out.println ( "! Buy result from the hand set is:" + A + "\ T" + B + "\ T" C + + "\ T" + + SUM Result);
myMoney1 + = Chip;
the System. out.println ( "your current remaining chips as" + myMoney1);
System.out.println ( "Do you continue the game (the y-/ the n-):?" );
sc = input.next ();
FLAG1 = to true ;
BREAK ;
} the else {
System.out.println ( "! Buy result from the hand set is:" + A + "\ T" + B + "\ T" C + + "\ T" + + SUM Result);
myMoney1 - = Chip;
IF ( myMoney1 <50 ) {
FLAG2 = false ;
FLAG1 = false ;
System.out.println ( "your current balance is:" + myMoney1 + "!, lack of balance, unable to continue the game" );
BREAK ;
} else {
System.out.println ( "Your current remaining chips as" + myMoney1);
System.out.println ( "Do you continue the game (the y-/ the n-):?" );
Sc = input.next ();
FLAG1 = to true ;
BREAK ;
}
}
}
// BREAK;
} the while (FLAG2);
} the else {
FLAG1 = false ;
Flag = false ;
BREAK ;
// System.out.println ( "Please confirm whether or not to start the game (the y-/ the n-)!");
}
} the while (FLAG1);
} the else {
Flag = false ;
System. out.println ( "you are out of chips, you can not play the game!" );
BREAK ;
}
BREAK ;
} the while (Flag);
System.out.println ( "Thank you for coming, I wish you happy!" );
}
}