Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Login2
- {
- static Account[] AccountData = new Account[33];
- public static void main(String[] args)
- {
- int INVALID = 0;
- boolean exitMain = false;
- Scanner in = new Scanner(System.in);
- AccountData[0] = new Account("kyle", 123, true);
- while (exitMain == false)
- {
- int accountNum = 0;
- if (INVALID % 2 == 0)
- {
- System.out.println("Create, Login, or Exit?");
- }
- INVALID++;
- String command = in.nextLine();
- command = command.toLowerCase();
- if (command.equals("create"))
- {
- boolean exitCreate = false;
- while (exitCreate == false)
- {
- System.out.println("Enter a username: ");
- String inputUser = in.nextLine();
- System.out.println("Enter a password PIN: ");
- int inputPass = in.nextInt();
- if (accountNum < 33)
- {
- AccountData[accountNum] = new Account(inputUser, inputPass, false);
- accountNum++;
- exitCreate = true;
- }
- else
- {
- System.out.println("Max Account Capacity");
- exitCreate = true;
- }
- }
- }
- else if (command.equals("login"))
- {
- System.out.println("Enter your username: ");
- String username = in.nextLine();
- System.out.println("Enter your password PIN: ");
- int password = in.nextInt();
- int search = 0;
- boolean exitLogin = false;
- while (exitLogin == false && search <= accountNum)
- {
- if(username.equals(AccountData[search].username) && password == AccountData[search].password && AccountData[search].admin == true)
- {
- System.out.println("Create Admin (create), Delete Account (delete), or Print?");
- while(exitLogin == false && search <= accountNum)
- {
- String option = in.nextLine();
- if(option.equals("create"))
- {
- System.out.println("Enter a username: ");
- String inputUser1 = in.nextLine();
- System.out.println("Enter a password PIN: ");
- int inputPass1 = in.nextInt();
- if (accountNum < 33)
- {
- AccountData[accountNum] = new Account(inputUser1, inputPass1, true);
- accountNum++;
- exitLogin = true;
- }
- else
- {
- System.out.println("Max Account Capacity");
- exitLogin = true;
- }
- }
- else if(option.equals("delete"))
- {
- System.out.println("Type the number for the account you want to remove:");
- int remove = in.nextInt();
- AccountData[remove] = new Account("", 0 , false);
- System.out.println("Successfully Removed.");
- exitLogin = true;
- }
- else if(option.equals("print"))
- {
- System.out.println("Usernames:" + AccountData[search].username);
- System.out.println("Passcodes:" + AccountData[search].password);
- exitLogin = true;
- }
- }
- }
- else if (username.equals(AccountData[search].username) && (password == AccountData[search].password && AccountData[search].admin == false))
- {
- System.out.println("Welcome!");
- exitLogin = true;
- exitMain = true;
- }
- search++;
- }
- }
- else if (command.equals("exit"))
- {
- System.out.println("Program will now exit.");
- exitMain = true;
- }
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement