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("gagandeep", 12345, true);
- int loginNumber = 1;
- while (account == false)
- {
- 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 input = in.nextLine();
- if(input.equals("create"))
- {
- System.out.println("Enter username for new admin: ");
- String adminUser = in.nextLine();
- System.out.println("Enter password for new admin: ");
- int adminPassword = in.nextInt();
- if (loginNumber < 33)
- {
- AccountData[loginNumber] = new Account2(adminUser, adminPassword, true);
- System.out.println("Account number " + loginNumber + " has been created");
- loginNumber++;
- login = true;
- }
- else
- {
- System.out.println("No more admins can be made fool");
- login = true;
- }
- }
- else if (input.equals("delete"))
- {
- System.out.println("What account number would you like to delete?");
- int remove = in.nextInt();
- int z = loginNumber;
- for(int i = 0; i < loginNumber - (remove + 1) ;i++)
- {
- AccountData[z-2] = AccountData[z-1];
- z--;
- }
- AccountData[loginNumber-1] = AccountData[loginNumber];
- System.out.println("Successfully Removed.");
- loginNumber--;
- login = true;
- }
- else if(input.equals("print"))
- {
- for(int i = 0; i <= loginNumber; i++)
- {
- System.out.println("Username: " + AccountData[i].username);
- System.out.println("Password: " + AccountData[i].password);
- }
- }
- }
- }
- else if (username.equals(AccountData[array].username) && (password == AccountData[array].password) && AccountData[array].admin == false)
- {
- System.out.println("BOSSSSS YOU MADE IT...now the code finna quit");
- login = true;
- account = true;
- }
- else
- {
- System.out.println("Login didn't work");
- }
- array++;
- }
- }
- else if (enter.equals("quit"))
- {
- System.out.println("Program will now quit");
- account = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement