Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package nea;
- import java.util.Random;
- import java.util.Scanner;
- /**
- *
- * @author 9400
- */
- public class NEA {
- /**
- * @param args the command line arguments
- */
- static int player1 = 0;
- static int player2 = 0;
- static Random rand = new Random();
- static String x;
- static String y;
- static Scanner s = new Scanner(System.in);
- static char User1;
- static char User2;
- public static void main(String[] args) {
- // TODO code application logic here
- int choice;
- do {
- System.out.println("Dice Game!");
- System.out.println("____________________");
- System.out.println("Main Menu: ");
- System.out.println("1 > Register");
- System.out.println("2 > Log-in & Play");
- System.out.println("3 > Hi-Scores");
- System.out.println("4 > Exit Game");
- System.out.println("____________________");
- System.out.println("Choose an option: 1-4");
- System.out.println("");
- choice = s.nextInt();
- s.skip("\n");
- switch (choice) {
- case 1:
- register();
- break;
- case 2:
- login();
- break;
- case 3:
- hiscores();
- break;
- case 4:
- System.out.println("Goodbye");
- System.exit(0);
- break;
- default:
- System.out.println("Invalid Option. Try Again");
- System.out.println("");
- break;
- }
- } while (choice != 4);
- }
- private static void register() {
- System.out.println("Create Username: ");
- System.out.println("Create Password: ");
- System.out.println("");
- }
- private static void login() {
- System.out.println("Enter Username: ");
- System.out.println("Enter Password: ");
- System.out.println("");
- for (int r = 1; r < 6; r++) {
- System.out.println("-------------Round " + r + "-------------");
- System.out.println("");
- System.out.println("Player 1: Enter any key to roll the dice");
- x = s.nextLine();
- int dice1 = Dice();
- System.out.println("Dice one: " + dice1);
- int dice2 = Dice();
- System.out.println("Dice two: " + dice2);
- int dice3 = 0;
- if (dice1 == dice2) {
- dice3 = Dice();
- System.out.println("Dice three: " + dice3);
- }
- int total = dice1 + dice2 + dice3;
- player1 = total + player1;
- if (player1 % 2 == 1) {
- player1 = player1 - 5;
- System.out.println("Player 1 score: " + player1);
- } else {
- player1 = player1 + 10;
- }
- if (player1 < 0) {
- player1 = 0;
- System.out.println(player1);
- }
- System.out.println("Player 1 score: " + player1);
- System.out.println("");
- System.out.println("Player 2: Enter any key to roll the dice");
- y = s.nextLine();
- dice1 = Dice();
- System.out.println("Dice one: " + dice1);
- dice2 = Dice();
- System.out.println("Dice two: " + dice2);
- dice3 = 0;
- if (dice1 == dice2) {
- dice3 = Dice();
- System.out.println("Dice three: " + dice3);
- }
- total = dice1 + dice2 + dice3;
- player2 = total + player2;
- if (player2 % 2 == 1) {
- player2 = player2 - 5;
- System.out.println("Player 2 score: " + player2);
- } else {
- player2 = player2 + 10;
- }
- if (player2 < 0) {
- player2 = 0;
- System.out.println(player2);
- }
- System.out.println("Player 2 score: " + player2);
- System.out.println("");
- if (player1>player2) {
- System.out.println("The Winner is: Player 1");
- System.out.println("");
- }
- else
- System.out.println("The Winner is: Player 2");
- System.out.println("");
- }
- if (player1==player2) {
- System.out.println("-------------Sudden Death-------------");
- }
- }
- private static void hiscores() {
- System.out.println("Hi-Scores: ");
- System.out.println("");
- System.out.println("1. ");
- System.out.println("2. ");
- System.out.println("3. ");
- System.out.println("4. ");
- System.out.println("5. ");
- System.out.println("");
- }
- private static void exit() {
- }
- private static int Dice() {
- return (rand.nextInt(6) + 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement