Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- import java.util.Scanner;
- /**
- *
- * @author 1LUNGUMAT
- */
- public class Summative2 {
- //Creating the scanner
- public static Scanner inputKeyboard = new Scanner(System.in);
- public static String[] nameDatabase = {"Rajat", "raZtek", "Matt", "Alan", "TravisLEE"};
- public static String[] passwordDatabase = {"Lol", "razersucksass", "roflmao", "holy", "chinawillrule"};
- public static String usernameEntered;
- public static String passwordEntered;
- public static boolean correct;
- public static int selection;
- public static int goBack;
- public static int selectionMainMenu2;
- public static boolean loggedin;
- public static void main(String[] args) {
- mainMenu();
- }
- public static void viewHighScores() {
- System.out.println("Works");
- }
- public static void login() {
- System.out.println("Enter Username: ");
- usernameEntered = inputKeyboard.next();
- System.out.println("Enter Password: ");
- passwordEntered = inputKeyboard.next();
- for (int index = 0; index < nameDatabase.length; index++) {
- if (usernameEntered.equals(nameDatabase[index]) && passwordEntered.equals(passwordDatabase[index])) {
- mainMenu2();
- } else {
- correct = false;
- }
- }
- correct = false;
- if (correct == false) {
- System.out.println("Wrong Username or Password");
- System.out.println("1. Try Again");
- System.out.println("2. Exit Math To The Max");
- System.out.println("Your choice: ");
- goBack = inputKeyboard.nextInt();
- if (goBack < 1 || goBack > 2) {
- System.out.println("Please enter 1 to Try Again and 2 to Exit.");
- }
- switch (goBack) {
- case 1:
- login();
- break;
- case 2:
- System.exit(goBack);
- }
- }
- }
- public static void mainMenu() {
- System.out.println("MAIN MENU");
- System.out.println("1. Exit");
- System.out.println("2. Login");
- System.out.println("Enter your choice: ");
- selection = inputKeyboard.nextInt();
- if (selection < 1 || selection > 2) {
- System.out.println("Please Enter 1 for Exit and 2 for Login.");
- }
- switch (selection) {
- case 1:
- System.exit(selection);
- break;
- case 2:
- login();
- break;
- }
- // if (correct == false) {
- // goBack = inputKeyboard.nextInt();
- // if (goBack < 1 || goBack > 2) {
- // System.out.println("Please enter 1 to Try Again and 2 to Exit.");
- // } else if (goBack == 1 && correct == false) {
- // login();
- // } else if (goBack == 2 && correct == false) {
- // System.out.println("You have exited Math To The Max.");
- // System.exit(goBack);
- // }
- // }
- }
- public static void mainMenu2() {
- System.out.println("Welcome " + usernameEntered);
- System.out.println("- MATH TO THE MAX MENU -");
- System.out.println("1. View High Scores");
- System.out.println("2. Play Addition To The Max");
- System.out.println("3. Play Subtraction To The Max");
- System.out.println("4. Play Multiplying To The Max");
- System.out.println("5. Play Division To The Max");
- System.out.println("6. Tutorial / FAQ");
- System.out.println("7. Exit");
- System.out.println("Enter your choice: ");
- selectionMainMenu2 = inputKeyboard.nextInt();
- if (selectionMainMenu2 < 1 || selectionMainMenu2 > 7) {
- System.out.println("Please Enter a Number Between 1 and 7.");
- } else if (selectionMainMenu2 == 1) {
- viewHighScores();
- } else if (selectionMainMenu2 == 2) {
- addition();
- } else if (selectionMainMenu2 == 3) {
- subtraction();
- } else if (selectionMainMenu2 == 4) {
- multiplying();
- }
- }
- }
- /**
- * @param args the command line arguments
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement