Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package arrays;
- import java.util.Scanner;
- public class AccountLogin2
- {
- static Account2[] AccountData = new Account2[33];
- public static void main(String []args)
- {
- int error = 0;
- boolean account = false;
- Scanner in = new Scanner(System.in);
- AccountData[0] = new Account2("ggd", 1, true);
- while (account == false)
- {
- int loginNumber = 1;
- if (error % 2 == 0)
- {
- System.out.println("Would you like to create an account, login, or quit?");
- }
- error++;
- String enter = in.nextLine();
- enter = enter.toLowerCase();
- if (enter.equals("create"))
- {
- boolean create = false;
- while (create == false)
- {
- System.out.println("Enter a username: ");
- String user = in.nextLine();
- System.out.println("Enter a password: ");
- int pass = in.nextInt();
- if (loginNumber < 33)
- {
- AccountData[loginNumber] = new Account2(user, pass, false);
- loginNumber++;
- create = true;
- }
- else
- {
- System.out.println("No mo accounts can b made fool");
- create = true;
- }
- }
- }
- else if (enter.equals("login"))
- {
- System.out.println("Enter your username: ");
- String username = in.nextLine();
- System.out.println("Enter your password: ");
- int password = in.nextInt();
- int array = 0;
- boolean login = false;
- while (array <= loginNumber && login == false)
- {
- if(username.equals(AccountData[array].username) && password == AccountData[array].password && AccountData[array].admin == true)
- {
- System.out.println("Hello Admin, would you like to create another administrator, delete an account, or print an account?");
- while (array <= loginNumber && login == false)
- {
- String option = in.nextLine();
- if (option.equals("create"))
- {
- System.out.println("Enter username for new admin: ");
- String adminUser = in.nextLine();
- System.out.println("Enter password for new admin: ");
- int adminPass = in.nextInt();
- if (loginNumber < 33)
- {
- AccountData[loginNumber] = new Account2(adminUser, adminPass, true);
- System.out.println("Account number " + loginNumber + " has been created");
- loginNumber++;
- login = true;
- }
- else
- {
- System.out.println("No mo accounts can b made fool");
- login = true;
- }
- }
- else if(option.equals("delete"))
- {
- System.out.println("What account number would you like to delete?");
- int delete = in.nextInt();
- int arrayValue = loginNumber;
- for(int i = 0; i < loginNumber - (delete + 1); i++)
- {
- AccountData[arrayValue - 2] = AccountData[arrayValue - 1];
- arrayValue--;
- }
- AccountData[loginNumber - 1] = AccountData[loginNumber];
- System.out.println("Account number " + loginNumber + " has been deleted");
- loginNumber--;
- login = true;
- }
- else if(option.equals("print"))
- {
- for(int i = 0; i <= loginNumber; i++)
- {
- System.out.println("Username: " + AccountData[i].username);
- System.out.println("Password: " + AccountData[i].password);
- }
- login = true;
- }
- }
- }
- else if (username.equals(AccountData[array].username) && (password == AccountData[array].password && AccountData[array].admin == false))
- {
- System.out.println("Logging in...");
- login = true;
- account = true;
- }
- else if (!username.equals(AccountData[array].username) && (password != AccountData[array].password))
- {
- System.out.println("Login did not work...");
- login = true;
- }
- array++;
- }
- }
- else if (enter.equals("quit"))
- {
- System.out.println("Program will now exit.");
- account = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement