Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "2":
- boolean add = true;
- boolean similar = true;
- while (add == true){
- for (int j = 0; j < 5; j++) {
- System.out.println("\nPlease re-enter password to confirm identity (Type 'cancel' to return to main menu): ");
- String confirmadd = input.nextLine();
- if (confirmadd.equalsIgnoreCase("cancel")){
- System.out.println("\nReturning to main menu...");
- add = false;
- break;
- } else if (confirmadd.equals(pass)){
- System.out.println("\nIdentity confirmed.");
- System.out.print("Enter product id (Type 'cancel' to return to menu): ");
- String id = input.nextLine();
- System.out.print("Enter product name (Type 'cancel' to return to menu): ");
- String title = input.nextLine();
- System.out.print("Enter product price (Type 'cancel' to return to menu): ");
- String price = input.nextLine();
- if
- if (id.equalsIgnoreCase("cancel") || title.equalsIgnoreCase("cancel") || price.equalsIgnoreCase("cancel")){
- System.out.println("Are you sure you want to cancel [Y/N]? ");
- String kensel = input.nextLine();
- if (kensel.equalsIgnoreCase("y")){
- System.out.println("\nReturning to main menu...");
- add = false;
- break;
- } else {
- continue;
- }
- } else {
- productid.add(id);
- producttitle.add(title);
- productprice.add(price);
- System.out.println("Item added.");
- }
- break;
- } else if (j==4){
- System.out.println("Too many attempts made. Please contact administrator.\n");
- boolean pleaselah = true;
- String username2;
- String password2;
- while (pleaselah == true) {
- System.out.print("Please enter admin username: ");
- username2 = input.nextLine();
- System.out.print("Please enter admin password: ");
- password2 = input.nextLine();
- MessageDigest adminhash = null;
- try {
- adminhash = MessageDigest.getInstance("MD5");
- } catch(NoSuchAlgorithmException e){
- }
- adminhash.reset();
- adminhash.update(password2.getBytes());
- byte[] digest2 = adminhash.digest();
- BigInteger bigint2 = new BigInteger(1,digest2);
- String adminhashed = bigint2.toString(16);
- while(adminhashed.length() < 32 ){
- adminhashed = "0" + adminhashed;
- }
- boolean enteradminid = adminnames.contains(username2);
- boolean enteradminpassword = adminpassword.contains(adminhashed);
- if (enteradminid == true && enteradminpassword == true){
- j = -1;
- System.out.println("Administrator credentials accepted. Please re-enter salesperson credentials.\n");
- pleaselah = false;
- } else {
- }//end if
- }//end for
- }//end if
- }//end for
- }//DO NOT TOUCH
- break;
- //-----------update product=======================================
- case "3":
- boolean update = true;
- while (update == true){
- for (int j = 0; j < 5; j++) {
- System.out.println("\nPlease re-enter password to confirm identity (Type 'cancel' to return to main menu): ");
- String confirmadd = input.nextLine();
- if (confirmadd.equalsIgnoreCase("cancel")){
- System.out.println("\nReturning to main menu...");
- update = false;
- break;
- } else if (confirmadd.equals(pass)){
- System.out.println("\nIdentity confirmed.");
- System.out.print("Enter product id (Type 'finish' to return to menu): ");
- String id = input.nextLine();
- if (id.equalsIgnoreCase("finish")){
- System.out.println("\nReturning to main menu...");
- update = false;
- break;
- } else {
- boolean found = productid.contains(id);
- if(found==true){
- int index = productid.indexOf(id);
- System.out.println("\nProduct ID found.\n");
- System.out.println("Product ID: " + productid.get(index));
- System.out.println("Product Title: " + producttitle.get(index));
- System.out.println("Product Price: " + productprice.get(index));
- System.out.println("Which would you like to update?");
- System.out.println("1) Product ID");
- System.out.println("2) Product Title");
- System.out.println("3) Product Price");
- System.out.println("4) All of the above");
- System.out.print("Enter operation number: ");
- String produpdate = input.nextLine();
- String newid = null;
- String newtitle = null;
- String newprice = null;
- switch (produpdate){
- case "1":
- System.out.println("Enter updated product ID value: ");
- newid = input.nextLine();
- productid.set(index, newid);
- System.out.println("\nItem updated.");
- break;
- case "2":
- System.out.println("Enter updated product title value: ");
- newtitle = input.nextLine();
- producttitle.set(index, newtitle);
- System.out.println("\nItem updated.");
- break;
- case "3":
- System.out.println("Enter updated product price value: ");
- newprice = input.nextLine();
- productprice.set(index, newprice);
- System.out.println("\nItem updated.");
- break;
- case "4":
- System.out.println("Enter updated product ID value: ");
- newid = input.nextLine();
- System.out.println("Enter updated product title value: ");
- newtitle = input.nextLine();
- System.out.println("Enter updated product price value: ");
- newprice = input.nextLine();
- productid.set(index, newid);
- producttitle.set(index, newtitle);
- productprice.set(index, newprice);
- System.out.println("\nItem updated.");
- break;
- default:
- System.out.println("Operation "+menu+" does not exist.");
- break;
- }
- } else if (found == false){
- System.out.println("ID not found. Please re-enter product ID.");
- }
- }
- break;
- } else if (j==4){
- System.out.println("Too many attempts made. Please contact administrator.\n");
- boolean pleaselah = true;
- String username2;
- String password2;
- while (pleaselah == true) {
- System.out.print("Please enter admin username: ");
- username2 = input.nextLine();
- System.out.print("Please enter admin password: ");
- password2 = input.nextLine();
- MessageDigest adminhash = null;
- try {
- adminhash = MessageDigest.getInstance("MD5");
- } catch(NoSuchAlgorithmException e){
- }
- adminhash.reset();
- adminhash.update(password2.getBytes());
- byte[] digest2 = adminhash.digest();
- BigInteger bigint2 = new BigInteger(1,digest2);
- String adminhashed = bigint2.toString(16);
- while(adminhashed.length() < 32 ){
- adminhashed = "0" + adminhashed;
- }
- boolean enteradminid = adminnames.contains(username2);
- boolean enteradminpassword = adminpassword.contains(adminhashed);
- if (enteradminid == true && enteradminpassword == true){
- j = -1;
- System.out.println("Administrator credentials accepted. Please re-enter salesperson credentials.\n");
- pleaselah = false;
- } else {
- }//end if
- }//end for
- }//end if
- }//end for
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement