Advertisement
Guest User

Will's Assessment V6

a guest
May 30th, 2017
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 23.22 KB | None | 0 0
  1. //29.5.17
  2. //Digital Technology Password Safe Assessment
  3. //Code By William Hollywood
  4.  
  5. package code;
  6.  
  7. import java.awt.GraphicsEnvironment;
  8. import java.io.Console;
  9. // Import libraries that get used
  10. import java.io.FileInputStream;
  11. import java.io.FileNotFoundException;
  12. import java.io.FileOutputStream;
  13. import java.io.IOException;
  14. import java.io.ObjectInputStream;
  15. import java.io.ObjectOutputStream;
  16. import java.io.PrintStream;
  17. import java.util.ArrayList;
  18. import java.util.InputMismatchException;
  19. import java.util.Scanner;
  20.  
  21. import javax.swing.JTextArea;
  22. import javax.swing.JFrame;
  23. import javax.swing.JPanel;
  24.  
  25. public class Start {
  26.  
  27.     Scanner in = new Scanner(System.in); //makes a scanner used to taking inputs
  28.     ArrayList<User> userDatabase; //defines the userDatabase array
  29.     private User loggedInUser; //makes a loggedInUser that is only accessable within  this start class
  30.  
  31.     String emailEnter = ""; //some variables used within the program
  32.     String passwordEnter = "";
  33.     int choice = -2;
  34.     int choice2 = 0;
  35.     boolean correctWebPass = false;
  36.     boolean correctUserPass = false;
  37.     String confirm;
  38.     String webOrPass;
  39.     String nameOrPass;
  40.     String newInfo;
  41.  
  42.     boolean exit = false; //used to know when to exit the whole program
  43.     static boolean loginCorrect = false; //used to check whether login the user entered is valid
  44.  
  45.  
  46.     public static void window(){ //function for making a GUI
  47.         JFrame frame = new JFrame(); //makes frame
  48.         frame.setResizable(false); //makes unresizable
  49.         frame.setSize(400, 400); //set size
  50.         frame.setLocationRelativeTo(null); //puts in middle of screen
  51.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //end program on gui close
  52.         frame.getContentPane().setLayout(null);
  53.  
  54.         JTextArea txtConsole = new JTextArea(); //makes text area
  55.         txtConsole.setBounds(6, 6, 388, 224); //sets text area size
  56.         frame.getContentPane().add(txtConsole);
  57.         frame.setVisible(true);
  58.         txtConsole.setEditable(false);
  59.  
  60.         PrintStream out = new PrintStream( new Frame( txtConsole ) ); //puts Textarea onto frame
  61.  
  62.         System.setOut( out ); //set output of console to text area
  63.         System.setErr( out ); //set error output of console to text area
  64.     }
  65.  
  66.     public void loadArrays(){ //function to load the array into the userDatabase so it can be read.
  67.         try {
  68.             String filename = System.getProperty("user.home") + "/users.ser"; //locates file users are stored in
  69.             FileInputStream fileIn = new FileInputStream(filename); //reads file
  70.             ObjectInputStream objin = new ObjectInputStream(fileIn);// redirects file read
  71.             userDatabase = (ArrayList<User>) objin.readObject(); //puts the users and their info into an arraylist
  72.             objin.close(); //closes reader
  73.             fileIn.close();
  74.         }catch(FileNotFoundException f){ // if file isnt found make a new array and add a default user
  75.             userDatabase = new ArrayList();
  76.             User test = new User("Test@test.com", "TestTest1!", "Testing User");
  77.             userDatabase.add(test);
  78.             test.webName.add("Facebook");
  79.             test.webName.add("Twitter");
  80.             test.webName.add("Google");
  81.             test.webPass.add("FacebookPass");
  82.             test.webPass.add("TwitterPass");
  83.             test.webPass.add("GooglePass");
  84.         }catch(IOException i) { //catches IO error so program doesnt crash
  85.             i.printStackTrace();
  86.             return;
  87.         }catch(ClassNotFoundException c) { //if user class isnt found print a stacktrace
  88.             System.out.println("User class not found");
  89.             c.printStackTrace();
  90.             return;
  91.         }
  92.     }
  93.  
  94.     public void saveArray(){ //exports the array into the file so it is saved for next time you login
  95.         try {
  96.             String filename = System.getProperty("user.home") + "/users.ser"; //locates file
  97.             FileOutputStream fileOut =
  98.                     new FileOutputStream(filename); //write to file located above
  99.             ObjectOutputStream out = new ObjectOutputStream(fileOut);
  100.             out.writeObject(userDatabase); //export the Database to the file
  101.             out.close();
  102.             fileOut.close(); //close writer
  103.             //System.out.println("Serialized data is saved in "+filename);
  104.         }catch(IOException i) { //catches IO error so program doesnt crash
  105.             i.printStackTrace();
  106.         }
  107.     }
  108.  
  109.     public void login(){ //login function
  110.         loginCorrect = false;
  111.         System.out.println("Please enter your email:"); //asks for email and saves it
  112.         emailEnter = in.next();
  113.         System.out.println("Please enter your password:");//asks for password and saves it
  114.         passwordEnter = in.next();
  115.         for (User u : userDatabase){ //for every user in userdatabase set 'u' to that user
  116.             //System.out.println(u); //checking users for debugging
  117.             try{
  118.                 if (emailEnter.equalsIgnoreCase(u.email) && passwordEnter.equals(u.password)){ //if email (non case sensitive) and password are correct do following
  119.                     loggedInUser = u;
  120.                     System.out.println("Login successful, Welcome "+loggedInUser.alias); //welcomes user using saved alias
  121.                     loginCorrect = true; //allows the loop to end
  122.                     return;
  123.                 }
  124.             }catch(NullPointerException e){
  125.  
  126.             }
  127.         }
  128.         if (loginCorrect == false){
  129.             System.out.println("Incorrect email or password");
  130.         }
  131.  
  132.     }
  133.  
  134.     public void register(){ //function that registers a new account
  135.         String newEmail = ""; //clears the info that will get inputed and resets some values used
  136.         String newPass = "";
  137.         String newAlias = "";
  138.         boolean passValid = false;
  139.         boolean passUpper = false;
  140.         boolean passLower = false;
  141.         boolean passNumber = false;
  142.         boolean passLen = false;
  143.         boolean passSym = false;
  144.         boolean passSpace = false;
  145.         boolean validregister = true;
  146.         boolean emailValid = false;
  147.         boolean emailDot = false;
  148.         boolean emailAt = false;
  149.         boolean emailSpace = false;
  150.         in.nextLine(); //clears scanner
  151.         while(emailValid == false){
  152.             System.out.println("What is your email?");
  153.             newEmail = in.nextLine(); //gets email
  154.             for (char c :newEmail.toCharArray()){ //converts the String input into single characters and checks them each to see if they match the following criteria
  155.                 if (c == '@'){ //check for @
  156.                     emailAt = true;
  157.                 }
  158.                 if (c == '.'){ //check for .
  159.                     emailDot = true;
  160.                 }
  161.                 if (Character.isSpaceChar(c)){ //check if a space
  162.                     emailSpace = true;
  163.                 }
  164.             }
  165.             if (emailAt == true && emailDot == true && emailSpace == false){//check if there is a '@' and a '.' but no spaces
  166.                 emailValid = true;
  167.             }
  168.             if(emailValid == false){ // if email isnt valid then do the loop again
  169.                 System.out.println("Invalid email please try again");
  170.                 System.out.println("");
  171.             }
  172.         }
  173.         while(passValid == false){ // loop for checking password is valid
  174.             System.out.println("What is your Password? (Must contain at least 1 lower case, 1 upper case, 1 number, 1 symbol, no spaces and 8 characters)");
  175.             newPass = in.nextLine(); //gets password
  176.             for (char c : newPass.toCharArray()){  //check every character in the input for the following
  177.                 if (Character.isUpperCase(c)){passUpper = true;}  //uppercase letter
  178.                 if (Character.isLowerCase(c)){passLower = true;} //lowercase letter
  179.                 if (Character.isDigit(c)){passNumber = true;} // number
  180.                 if (!Character.isLetterOrDigit(c) && !Character.isSpaceChar(c)){passSym = true;} //symbol (character that isnt a digit or letter)
  181.                 if (Character.isSpaceChar(c)){passSpace = true;} //check for space
  182.             }
  183.             if (newPass.length() >= 8){passLen = true;} //length of input equal to or longer than 8 characters
  184.             if (passUpper == true && passLower == true && passNumber == true && passSym == true && passSpace == false && passLen == true){ // checks to make sure all criteria are met
  185.                 passValid = true;
  186.             }
  187.             if(passValid == false){ //if password doesnt fill all critera say they need to reinput it
  188.                 System.out.println("Please enter a password which meets all the requirements");
  189.                 System.out.println("");
  190.             }
  191.         }
  192.         System.out.println("What is your Name?");
  193.         newAlias = in.nextLine();
  194.         for (User u : userDatabase){ //set u to every user in userdatabase
  195.             //System.out.println(u);
  196.             try{
  197.                 if (newEmail.equalsIgnoreCase(u.email)){ //checks if email is already taken
  198.                     System.out.println("");
  199.                     System.out.println("Email already registered to an account, please try a different email next time");
  200.                     System.out.println("");
  201.                     validregister = false;
  202.                 }
  203.             }catch(NullPointerException e){ //catches null users
  204.  
  205.             }
  206.         }
  207.         if(validregister == true){ //if email isnt taken
  208.             userDatabase.add(new User(newEmail, newPass, newAlias));// add the information inputted above into the userdatabase
  209.             System.out.println("User saved, you can now login using the following credentials");
  210.             System.out.println("Email: "+newEmail);
  211.             System.out.println("Password: "+newPass);
  212.             System.out.println("");
  213.         }
  214.     }
  215.  
  216.     public void choiceLoginRego(){ //gets whether the user wants to make a new account or register for a new one
  217.         while (choice <= 0 || choice >= 3){ //ensures input is 1 or 2
  218.             System.out.println("Do you want to sign in as an existing user (1) or register as a new one(2)?");
  219.             try {
  220.                 choice = in.nextInt();
  221.             }catch(InputMismatchException e) { //doesnt allow any other input except for an int
  222.                 System.out.println("Please Enter A Valid Input");
  223.                 in.next();
  224.                 System.out.println("");
  225.             }
  226.         }
  227.     }
  228.  
  229.     public void choiceApp(){ //gets what app the user wants to use
  230.         System.out.println("What do you want to do?");
  231.         System.out.println("1. Check existing websites and passwords");
  232.         System.out.println("2. Add new website and password");
  233.         System.out.println("3. Delete a stored website and password");
  234.         System.out.println("4. Change website name and/or password");
  235.         System.out.println("5. Change login information");
  236.         System.out.println("6. Exit");
  237.         while (choice <= 0 || choice >= 7){ //ensures input is within 1-5
  238.             System.out.println("Please enter the corresponding number for what you want to do");
  239.             try {
  240.                 choice = in.nextInt();
  241.             }catch(InputMismatchException e) { //doesnt allow any inputs except for an int
  242.                 System.out.println("Please Enter A Valid Input");
  243.                 in.next();
  244.                 System.out.println("");
  245.             }
  246.         }
  247.     }
  248.  
  249.     public void delWebpass(){
  250.         boolean delWeb = false;
  251.         while(delWeb == false){
  252.             System.out.println("");
  253.             System.out.println("Which website do you want to delete? (input 0 to cancel)");
  254.             for (int i = 0;(i < loggedInUser.webName.size());i++){
  255.                 System.out.println((i+1)+". "+loggedInUser.webName.get(i));
  256.             }
  257.             int delNum = -2;
  258.             while (delNum <= -1 || delNum >= (loggedInUser.webName.size() + 1)){ //ensures input is within 1-5
  259.                 System.out.println("Please enter the corresponding number for what you want to remove");
  260.                 try {
  261.                     delNum = in.nextInt();
  262.                 }catch(InputMismatchException e) { //doesnt allow any inputs except for an int
  263.                     System.out.println("Please Enter A Valid Input");
  264.                     in.next();
  265.                     System.out.println("");
  266.                 }
  267.             }
  268.             if (delNum == 0){
  269.                 delWeb = true;
  270.             }else{
  271.                 System.out.println("You have chosen to delete "+loggedInUser.webName.get(delNum-1)+ " is this correct?");
  272.                 System.out.println("Yes or No? (Any other input other than 'Yes' or 'No' will be automatically counted as a 'No')");
  273.                 in.nextLine();
  274.                 confirm = in.nextLine(); // gets whether they have put in the correct info
  275.                 if(confirm.equalsIgnoreCase("Yes")){ //if answer is yes end the loop
  276.                     loggedInUser.webName.remove(delNum-1);
  277.                     loggedInUser.webPass.remove(delNum-1);
  278.                     delWeb = true;
  279.                     System.out.println("Website deleted");
  280.                     System.out.println("");
  281.                 }else{
  282.                     if(confirm.equalsIgnoreCase("No")){ //if answer is no redo the loop
  283.                         delWeb = false;
  284.                     }else{//else redo the loop
  285.                         delWeb = false;
  286.                     }
  287.                 }
  288.             }
  289.         }
  290.     }
  291.  
  292.     public void checkWebpass(){ //app to check all websites and passwords
  293.         if (loggedInUser.webName.size()>0){
  294.             System.out.println("You have passwords saved for the following websites:");
  295.             System.out.println("");
  296.             for (int i = 0;(i < loggedInUser.webName.size());i++){ //prints full website list by iterating through the array
  297.                 System.out.println((i+1)+". "+loggedInUser.webName.get(i)); // output EG. "1. Facebook"
  298.             }
  299.             System.out.println("");
  300.             choice = 0;
  301.             while (choice <= 0 || choice >= (loggedInUser.webName.size()+1)){ // ensures input is within 1-(amount of websites in array)
  302.                 System.out.println("Please enter the corresponding number for what password you want to see");
  303.                 try {
  304.                     choice = in.nextInt();
  305.                 }catch(InputMismatchException e) { //doesnt allow inputs except for a int
  306.                     System.out.println("Please Enter A Valid Input");
  307.                     in.next();
  308.                     System.out.println("");
  309.                 }
  310.             }
  311.             System.out.println("");
  312.             System.out.println("Your saved password for "+loggedInUser.webName.get((choice-1))+" is: "+loggedInUser.webPass.get((choice-1))); //prints selected website and password for website
  313.             System.out.println("");
  314.         }else{
  315.             if(loggedInUser.webName.size()<=0){
  316.                 System.out.println("");
  317.                 System.out.println("You have no passwords saved for any websites");
  318.                 System.out.println("");
  319.             }
  320.         }
  321.  
  322.     }
  323.  
  324.     public void addWebpass(){ //function to add a website and password
  325.         int i = 1; //interger used for iterating
  326.         String addNewWeb = null; //clears website and password
  327.         String addNewPass = null;
  328.         correctWebPass = false;
  329.         while (correctWebPass == false){
  330.             System.out.println("");
  331.             System.out.println("What is the name of the website you want to add?");
  332.             if(i == 1){in.nextLine();i++;} //used on first runthrough to clear the scanner and add 1 to i so that it wont run again
  333.             addNewWeb = in.nextLine(); //saves Website from user
  334.             System.out.println("");
  335.             System.out.println("What is the password for this site?");
  336.             addNewPass = in.nextLine(); //saves password from user
  337.             System.out.println("");
  338.             System.out.println("Is this information correct?");
  339.             System.out.println("Website: "+addNewWeb);
  340.             System.out.println("Password: "+addNewPass);
  341.             System.out.println("Yes or No? (Any other input other than 'Yes' or 'No' will be automatically counted as a 'No')");
  342.             confirm = in.nextLine();
  343.             if(confirm.equalsIgnoreCase("Yes")){//confirms whether input was yes
  344.                 correctWebPass = true;
  345.             }else{
  346.                 if(confirm.equalsIgnoreCase("No")){//confirms whether input was no
  347.                     correctWebPass = false;
  348.                 }else{ //if input is anything else
  349.                     correctWebPass = false;//boolean that ends/continues add website loop
  350.                 }
  351.             }
  352.         }
  353.         System.out.println("");
  354.         System.out.println("The following information has been stored"); //Prints what info was saved
  355.         System.out.println("Website: "+addNewWeb);
  356.         System.out.println("Password: "+addNewPass);
  357.         System.out.println("");
  358.         loggedInUser.webName.add(addNewWeb);
  359.         loggedInUser.webPass.add(addNewPass);
  360.         //System.out.println(userDatabase);
  361.  
  362.     }
  363.  
  364.     public void changeWebpass(){ //app that changes the website name or website password for a specific website
  365.         correctWebPass = false;
  366.         if (loggedInUser.webName.size() == 0){
  367.             System.out.println("");
  368.             System.out.println("No passwords stored for any sites");
  369.             System.out.println("");
  370.         }else{
  371.             while (correctWebPass == false){ //loops so that the user can retry putting in the specifics
  372.                 System.out.println("What website do you want to change information for?");
  373.                 for (int x = 0;(x < loggedInUser.webPass.size());x++){ //prints a line of all the websites and passwords in the arraylist
  374.                     System.out.println((x+1)+". "+loggedInUser.webName.get(x)+", Password: "+loggedInUser.webPass.get(x));
  375.                 }
  376.  
  377.                 choice = 0;
  378.                 while (choice <= 0 || choice >= (loggedInUser.webName.size()+1)){ //ensures user inputs a number that is relative to the websites in the list
  379.                     System.out.println("");
  380.                     System.out.println("What is the number of the data set you want to change?");
  381.                     try {
  382.                         choice = in.nextInt(); //gets choice that user wants
  383.                     }catch(InputMismatchException e) {
  384.                         System.out.println("Please Enter A Valid Input"); //checks whether input was an input other than an int
  385.                         in.next();
  386.                     }
  387.                 }
  388.                 System.out.println("You have chosen to change the "+loggedInUser.webName.get(choice-1)+" login"); //displays website that was chosen
  389.  
  390.                 choice2 = 0; //resets the chocie for username or password
  391.                 while (choice2 <= 0 || choice2 >= 3){ //ensures user inputs an int (1 or 2)
  392.                     System.out.println("");
  393.                     System.out.println("Do you want to change the name (1) or password (2) for "+loggedInUser.webName.get(choice-1));
  394.                     try {
  395.                         choice2 = in.nextInt();
  396.                     }catch(InputMismatchException e) { //catches whether input is not an int
  397.                         System.out.println("Please Enter A Valid Input");
  398.                         System.out.println("");
  399.                         in.next();
  400.                     }
  401.                 }
  402.  
  403.                 if (choice2 == 1){webOrPass = "Name";} //sets variable to name or password so it can be used below
  404.                 if (choice2 == 2){webOrPass = "Password";}
  405.                 System.out.println("");
  406.                 System.out.println("You have chosen to change the "+webOrPass+" of the website"); //prints what they've chosen
  407.                 System.out.println("What do you want to change the "+webOrPass+ " to?"); //asks what they want to change the password to
  408.                 in.nextLine();newInfo = in.nextLine(); //clears scanner then gets the new name or password
  409.                 System.out.println("");
  410.                 System.out.println("Is this information correct?");
  411.                 if (choice2 == 1){ //prints new website name and password
  412.                     System.out.println("Website: "+newInfo);
  413.                     System.out.println("Password: "+loggedInUser.webPass.get(choice-1));
  414.                 }
  415.                 if (choice2 == 2){//prints website name and new password
  416.                     System.out.println("Website: "+loggedInUser.webName.get(choice-1));
  417.                     System.out.println("Password: "+newInfo);
  418.                 }
  419.                 System.out.println("Yes or No? (Any other input other than 'Yes' or 'No' will be automatically counted as a 'No')");
  420.                 confirm = in.nextLine(); // gets whether they have put in the correct info
  421.                 if(confirm.equalsIgnoreCase("Yes")){ //if answer is yes end the loop
  422.                     correctWebPass = true;
  423.                 }else{
  424.                     if(confirm.equalsIgnoreCase("No")){ //if answer is no redo the loop
  425.                         correctWebPass = false;
  426.                     }else{//else redo the loop
  427.                         correctWebPass = false;
  428.                     }
  429.                 }
  430.             }
  431.             System.out.println("");
  432.             System.out.println("The following information has been stored");
  433.             if (choice2 == 1){//sets website name to the new one
  434.                 loggedInUser.webName.set(choice-1, newInfo);
  435.             }
  436.             if (choice2 == 2){//sets website password to the new one
  437.                 loggedInUser.webPass.set(choice-1, newInfo);
  438.             }
  439.             System.out.println("Website: "+loggedInUser.webName.get(choice-1)); //prints new info
  440.             System.out.println("Password: "+loggedInUser.webPass.get(choice-1));
  441.         }
  442.     }
  443.  
  444.     public void changeLogin(){ //app that changes the
  445.         correctUserPass = false;
  446.         while (correctUserPass == false){
  447.             choice = 0;
  448.             while (choice <= 0 || choice >= 3){
  449.                 System.out.println("Do you want to change your email (1) or password (2)");
  450.                 try {
  451.                     choice = in.nextInt();
  452.                 }catch(InputMismatchException e) {
  453.                     System.out.println("Please Enter A Valid Input");
  454.                     in.next();
  455.                 }
  456.             }
  457.             if (choice == 1){nameOrPass = "Email";}
  458.             if (choice == 2){nameOrPass = "Password";}
  459.  
  460.             System.out.println("You have chosen to change your " +nameOrPass);
  461.  
  462.             System.out.println("What do you want to change your "+nameOrPass+ " to?");
  463.             if (choice == 1){
  464.                 in.nextLine();
  465.                 newInfo = in.nextLine();
  466.             }
  467.  
  468.             if(choice == 2){
  469.                 boolean passValid = false;
  470.                 boolean passUpper = false;
  471.                 boolean passLower = false;
  472.                 boolean passNumber = false;
  473.                 boolean passLen = false;
  474.                 boolean passSym = false;
  475.                 boolean passSpace = false;
  476.                 int i = 0;
  477.  
  478.                 while(passValid == false){
  479.                     System.out.println("(Must contain at least 1 lower case, 1 upper case, 1 number, 1 symbol, no spaces and 8 characters)");
  480.                     if (i==0){in.nextLine();i++;}
  481.                     newInfo = in.nextLine(); //gets password
  482.                     for (char c : newInfo.toCharArray()){  //check every character in the input for the following
  483.                         if (Character.isUpperCase(c)){passUpper = true;}  //uppercase letter
  484.                         if (Character.isLowerCase(c)){passLower = true;} //lowercase letter
  485.                         if (Character.isDigit(c)){passNumber = true;} // number
  486.                         if (!Character.isLetterOrDigit(c) && !Character.isSpaceChar(c)){passSym = true;} //symbol (character that isnt a digit or letter)
  487.                         if (Character.isSpaceChar(c)){passSpace = true;} //check for space
  488.                     }
  489.                     if (newInfo.length() >= 8){passLen = true;} //length of input equal to or longer than 8 characters
  490.                     if (passUpper == true && passLower == true && passNumber == true && passSym == true && passSpace == false && passLen == true){ // checks to make sure all criteria are met
  491.                         passValid = true;
  492.                     }
  493.                     if(passValid == false){ //if password doesnt fill all critera say they need to reinput it
  494.                         System.out.println("Please enter a password which meets all the requirements");
  495.                     }
  496.                 }
  497.             }
  498.  
  499.             System.out.println("Is this information correct?");
  500.             if (choice == 1){
  501.                 System.out.println("Email: "+newInfo);
  502.                 System.out.println("Password: "+loggedInUser.password);
  503.             }
  504.             if (choice == 2){
  505.                 System.out.println("Email: "+loggedInUser.email);
  506.                 System.out.println("Password: "+newInfo);
  507.             }
  508.             System.out.println("Yes or No? (Any other input other than 'Yes' or 'No' will be automatically counted as a 'No')");
  509.             confirm = in.nextLine();
  510.             if(confirm.equalsIgnoreCase("Yes")){
  511.                 correctUserPass = true;
  512.             }else{
  513.                 if(confirm.equalsIgnoreCase("No")){
  514.                     correctUserPass = false;
  515.                 }else{
  516.                     correctUserPass = false;
  517.                 }
  518.             }
  519.         }
  520.         System.out.println("The following information has been stored");
  521.         if (choice == 1){
  522.             loggedInUser.email = newInfo;
  523.         }
  524.         if (choice == 2){
  525.             loggedInUser.password = newInfo;
  526.         }
  527.         System.out.println("Email: "+loggedInUser.email);
  528.         System.out.println("Password: "+loggedInUser.password);
  529.         System.out.println("");
  530.         //System.out.println(userDatabase);
  531.     }
  532.  
  533.     public void exit(){
  534.         System.out.println("Are you sure you want to exit?");
  535.         System.out.println("Yes or No? (Any other input other than 'Yes' or 'No' will be automatically counted as a 'No')");
  536.         confirm = in.nextLine();
  537.         confirm = in.nextLine();
  538.         if(confirm.equalsIgnoreCase("Yes")){ //checks if input = yes ignoring capital letters
  539.             exit = true;
  540.             System.out.println("Password Safe closed, thank you for using.");
  541.         }else{
  542.             if(confirm.equalsIgnoreCase("No")){ //checks if input = no ignoring capital letters
  543.                 exit = false;
  544.             }else{
  545.                 exit = false;
  546.             }
  547.         }
  548.     }
  549.  
  550.     public static void main(String [] orgs) {
  551.         Start start = new Start();
  552.         //window();
  553.  
  554.         System.out.println("Testing User credentials:");
  555.         System.out.println("Email: Test@test.com");
  556.         System.out.println("Password: TestTest1!");
  557.         start.loadArrays();
  558.         start.saveArray();
  559.         while (loginCorrect == false){
  560.             //System.out.println(start.userDatabase);
  561.             start.choice = 0;
  562.             start.choiceLoginRego();
  563.             if(start.choice == 1){start.login();}
  564.             if(start.choice == 2){start.register();start.saveArray();start.loadArrays();}
  565.         }
  566.         while(start.exit == false){
  567.             start.choice = 0;
  568.             start.choiceApp();
  569.             if(start.choice == 1){start.checkWebpass();start.choice =0;}
  570.             if(start.choice == 2){start.addWebpass();start.choice =0;}
  571.             if(start.choice == 3){start.delWebpass();start.choice =0;}
  572.             if(start.choice == 4){start.changeWebpass();start.choice =0;}
  573.             if(start.choice == 5){start.changeLogin();start.choice =0;}
  574.             if(start.choice == 6){start.exit();start.choice =0;}
  575.             start.saveArray();
  576.         }
  577.     }
  578. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement