Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6.  
  7. import java.util.Scanner;
  8.  
  9. /**
  10. *
  11. * @author 1LUNGUMAT
  12. */
  13. public class NewClass {
  14. //Creating the scanner
  15.  
  16. public static Scanner inputKeyboard = new Scanner(System.in);
  17. public static String[] nameDatabase = {"Rajat", "raZtek", "Matt", "Alan", "TravisLEE"};
  18. public static String[] passwordDatabase = {"Lol", "razersucksass", "roflmao", "holy", "chinawillrule"};
  19. public static String usernameEntered;
  20. public static String passwordEntered;
  21. public static boolean correct;
  22. public static int selection;
  23. public static int goBack;
  24. public static int selectionMainMenu2;
  25. public static boolean loggedin;
  26.  
  27. public static void main(String[] args) {
  28. mainMenu();
  29. }
  30.  
  31. public static void viewHighScores() {
  32. System.out.println("Works");
  33. }
  34.  
  35. public static void login() {
  36. System.out.println("Enter Username: ");
  37. usernameEntered = inputKeyboard.next();
  38. System.out.println("Enter Password: ");
  39. passwordEntered = inputKeyboard.next();
  40. for (int index = 0; index < nameDatabase.length; index++) {
  41. if (usernameEntered.equals(nameDatabase[index]) && passwordEntered.equals(passwordDatabase[index])) {
  42. mainMenu2();
  43. correct=true;
  44. break;
  45. } else {
  46. correct = false;
  47. }
  48. }
  49. //correct = false;
  50. if (correct == false) {
  51. System.out.println("Wrong Username or Password");
  52. System.out.println("1. Try Again");
  53. System.out.println("2. Exit Math To The Max");
  54. System.out.println("Your choice: ");
  55. goBack = inputKeyboard.nextInt();
  56. if (goBack < 1 || goBack > 2) {
  57. System.out.println("Please enter 1 to Try Again and 2 to Exit.");
  58. }
  59. switch (goBack) {
  60. case 1:
  61. login();
  62. break;
  63. case 2:
  64. System.exit(goBack);
  65. }
  66. }
  67. }
  68.  
  69. public static void mainMenu() {
  70. System.out.println("MAIN MENU");
  71. System.out.println("1. Exit");
  72. System.out.println("2. Login");
  73. System.out.println("Enter your choice: ");
  74. selection = inputKeyboard.nextInt();
  75. if (selection < 1 || selection > 2) {
  76. System.out.println("Please Enter 1 for Exit and 2 for Login.");
  77. }
  78. switch (selection) {
  79. case 1:
  80. System.exit(selection);
  81. break;
  82. case 2:
  83. login();
  84. break;
  85. }
  86. // if (correct == false) {
  87. // goBack = inputKeyboard.nextInt();
  88. // if (goBack < 1 || goBack > 2) {
  89. // System.out.println("Please enter 1 to Try Again and 2 to Exit.");
  90. // } else if (goBack == 1 && correct == false) {
  91. // login();
  92. // } else if (goBack == 2 && correct == false) {
  93. // System.out.println("You have exited Math To The Max.");
  94. // System.exit(goBack);
  95. // }
  96. // }
  97. }
  98.  
  99. public static void mainMenu2() {
  100. System.out.println("Welcome " + usernameEntered);
  101. System.out.println("- MATH TO THE MAX MENU -");
  102. System.out.println("1. View High Scores");
  103. System.out.println("2. Play Addition To The Max");
  104. System.out.println("3. Play Subtraction To The Max");
  105. System.out.println("4. Play Multiplying To The Max");
  106. System.out.println("5. Play Division To The Max");
  107. System.out.println("6. Tutorial / FAQ");
  108. System.out.println("7. Exit");
  109. System.out.println("Enter your choice: ");
  110. selectionMainMenu2 = inputKeyboard.nextInt();
  111. if (selectionMainMenu2 < 1 || selectionMainMenu2 > 7) {
  112. System.out.println("Please Enter a Number Between 1 and 7.");
  113.  
  114.  
  115. } else if (selectionMainMenu2 == 1) {
  116. viewHighScores();
  117.  
  118.  
  119. } else if (selectionMainMenu2 == 2) {
  120. //addition();
  121.  
  122.  
  123. } else if (selectionMainMenu2 == 3) {
  124. //subtraction();
  125.  
  126.  
  127. } else if (selectionMainMenu2 == 4) {
  128. // multiplying();
  129.  
  130. }
  131. }
  132. }
  133. /**
  134. * @param args the command line arguments
  135. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement