Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package nea;
  7.  
  8. import java.util.Random;
  9. import java.util.Scanner;
  10.  
  11. /**
  12. *
  13. * @author 9400
  14. */
  15. public class NEA {
  16.  
  17. /**
  18. * @param args the command line arguments
  19. */
  20. static int player1 = 0;
  21. static int player2 = 0;
  22. static Random rand = new Random();
  23. static String x;
  24. static String y;
  25. static Scanner s = new Scanner(System.in);
  26. public static void main(String[] args) {
  27. // TODO code application logic here
  28.  
  29.  
  30. int choice;
  31. do {
  32. System.out.println("Dice Game!");
  33. System.out.println("____________________");
  34. System.out.println("Main Menu: ");
  35. System.out.println("1 > Register");
  36. System.out.println("2 > Log-in & Play");
  37. System.out.println("3 > Hi-Scores");
  38. System.out.println("4 > Exit Game");
  39. System.out.println("____________________");
  40. System.out.println("Choose an option: 1-4");
  41. System.out.println("");
  42. choice = s.nextInt();
  43. s.skip("\n");
  44.  
  45. switch (choice) {
  46. case 1:
  47. register();
  48. break;
  49. case 2:
  50. login();
  51. break;
  52. case 3:
  53. hiscores();
  54. break;
  55. case 4:
  56. System.out.println("Goodbye");
  57. System.exit(0);
  58. break;
  59. default:
  60. System.out.println("Invalid Option. Try Again");
  61. System.out.println("");
  62. break;
  63. }
  64. } while (choice != 4);
  65. }
  66.  
  67. private static void register() {
  68. System.out.println("Create Username: ");
  69.  
  70. System.out.println("Create Password: ");
  71. System.out.println("");
  72. }
  73.  
  74. private static void login() {
  75. System.out.println("Enter Username: ");
  76. System.out.println("Enter Password: ");
  77. System.out.println("");
  78.  
  79. for (int r = 1; r < 6; r++) {
  80. System.out.println("Round " + r);
  81. System.out.println("Player 1: Enter any key to roll the dice");
  82. x = s.nextLine();
  83. int dice1 = Dice();
  84. System.out.println("Dice one: " + dice1);
  85. int dice2 = Dice();
  86. System.out.println("Dice two: " + dice2);
  87. int dice3 = 0;
  88. if (dice1 == dice2) {
  89. dice3 = Dice();
  90. System.out.println(dice3);
  91. }
  92. int total = dice1 + dice2 + dice3;
  93. player1 = total + player1;
  94. if (player1 % 2 == 1) {
  95. player1 = player1 - 5;
  96. System.out.println("Player 1 score: " + player1);
  97. } else {
  98. player1 = player1 + 10;
  99. System.out.println("Player 1 score: " + player1);
  100. }
  101.  
  102. System.out.println("Player 1: Enter any key to roll the dice");
  103. y = s.nextLine();
  104. dice1 = Dice();
  105. System.out.println("Dice one: " + dice1);
  106. dice2 = Dice();
  107. System.out.println("Dice two: " + dice2);
  108. dice3 = 0;
  109. if (dice1 == dice2) {
  110. dice3 = Dice();
  111. System.out.println(dice3);
  112. }
  113. total = dice1 + dice2 + dice3;
  114. player2 = total + player2;
  115.  
  116. if (player2 % 2 == 1) {
  117. player2 = player2 - 5;
  118. System.out.println("Player 2 score: " + player2);
  119. } else {
  120. player2 = player2 + 10;
  121. System.out.println("Player 2 score: " + player2);
  122. }
  123. }
  124. }
  125.  
  126. private static void hiscores() {
  127. System.out.println("Hi-Scores: ");
  128. System.out.println("");
  129. System.out.println("1. ");
  130. System.out.println("2. ");
  131. System.out.println("3. ");
  132. System.out.println("4. ");
  133. System.out.println("5. ");
  134. System.out.println("");
  135. }
  136.  
  137. private static void exit() {
  138. }
  139.  
  140. private static int Dice() {
  141. return (rand.nextInt(6) + 1);
  142. }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement