Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner user_input = new Scanner(System.in);
- One_dice oneDice = new One_dice();
- Two_dice twoDice = new Two_dice();
- boolean exit = false;
- System.out.println("Welcome to the Dice Roll Calculator!");
- while (exit == false)
- {
- System.out.println("Would you like to roll a dice? y/n");
- String input = user_input.nextLine();
- if (input.equals("y"))
- {
- System.out.println("How many sides do you want on "
- + "your dice?");
- int userSize = user_input.nextInt();
- oneDice.SetDiceRoll(userSize);
- System.out.println("The result was: " +
- oneDice.GetDiceValue());
- System.out.println("Would you like to roll two dice? y/n");
- user_input.nextLine();
- if (input.equals("y"))
- {
- System.out.println("How many sides do you want on "
- + "your dice?");
- int userSize2 = user_input.nextInt();
- oneDice.SetDiceRoll(userSize2);
- twoDice.SetDiceRoll(userSize2);
- System.out.println("The result was: " +
- oneDice.GetDiceValue() + " and " + twoDice.GetDiceValue());
- }
- }
- else
- {
- System.out.println("You chose not to roll. "
- + "Would you like to exit the program?");
- input = user_input.nextLine();
- if (input.equals("y"))
- {
- exit = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement