Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.String;
- import java.util.Scanner;
- public class CrapTableMachine{
- public static(String []) {
- Scanner.input = new Scanner;
- int dice1 = 0, dice2 = 0, starter, addedRoll;
- String nameOfRoll;
- System.out.print("\f"); \\clear the field
- System.out.print("Welcome to the Craps Table!\n"); \\ Title
- System.out.print("Enter anything to roll or 0 to quit: ");
- starter = input.nextInt();
- \\Get the random numbers for the dice.
- dice1 = 1 + (int)(Math.random() * ((6 - 1) + 1));
- dice2 = 1 + (int)(Math.random() * ((6 - 1) + 1));
- addedRoll = dice1 + dice2;
- \\waits for the player to enter anything showing that they are ready. If they enter 0 the program ends.
- do{
- if(addedRoll == 12){nameOfRoll = "Box-Cars!"; }
- else if(addedRoll == 11){nameOfRoll = "Yo-Leven!"; }
- else if(addedRoll == 2){nameOfRoll = "Snake Eyes!"; }
- else if(addedRoll == 3){nameOfRoll = "Ace-Duece!"; }
- else if(addedRoll == 5){nameOfRoll = "Fever Five!"; }
- else if(addedRoll == 7){nameOfRoll = "Seven out!"; }
- else if(addedRoll == 9){nameOfRoll = "Nina!"; }
- if(addedRoll == 4){ if(dice1 == dice2){nameOfRoll = "Hard Four!";}else{nameOfRoll = "Easy Four!";} }
- else if(addedRoll == 6){if(dice1 == dice2){nameOfRoll = "Hard Six!";}else{nameOfRoll = "Easy Six!";} }
- else if(addedRoll == 8){if(dice1 == dice2){nameOfRoll = "Hard Eight!";}else{nameOfRoll = "Easy Eight!";} }
- else if(addedRoll == 10){if(dice1 == dice2){nameOfRoll = "Hard Ten!";}else{nameOfRoll = "Easy Ten!";} }
- System.out.print("" + dice1); \\ Show dice rolls and what they are called.
- System.out.print("" + dice2);
- System.out.print("" + nameOfRoll);
- starter = 0;
- }while (starter != 0);
- System.out.print("\n" + "Game Over.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment