Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DiceGame
- {
- static int diceX(int minX, int maxX)
- {
- int x = (int)(Math.random() * (((maxX + 1) - (minX)) + 1));
- return x;
- }
- static int diceY(int minY, int maxY)
- {
- int y = (int)(Math.random() * (((maxY + 1) - (minY)) + 1));
- return y;
- }
- public static void main(String [] args)
- {
- System.out.println("Would you like to play? (y/n) ");
- String responseLine = Console.readString();
- char response = responseLine.charAt(0);
- if(response == 'y')
- {
- System.out.println("Dice1 rolled " + diceX(1, 6));
- System.out.println("Dice2 rolled " + diceY(1, 6));
- System.out.println((diceX(1, 6) + diceY(1, 6)));
- int x = diceX(1, 6);
- int y = diceY(1, 6);
- int s = x + y;
- if((s == 2)) // (s == 3) // (s == 11) // (s == 12))
- {
- System.out.println("Score: " + s);
- System.out.println("You win");
- }
- if(s == 7)
- {
- System.out.println("Score: " + s);
- System.out.println("You Lose");
- }
- }
- if(response == 'n')
- {
- ;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement