Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 KB | None | 0 0
  1. case "2":
  2. boolean add = true;
  3. boolean similar = true;
  4.  
  5. while (add == true){
  6. for (int j = 0; j < 5; j++) {
  7. System.out.println("\nPlease re-enter password to confirm identity (Type 'cancel' to return to main menu): ");
  8. String confirmadd = input.nextLine();
  9.  
  10. if (confirmadd.equalsIgnoreCase("cancel")){
  11. System.out.println("\nReturning to main menu...");
  12. add = false;
  13. break;
  14. } else if (confirmadd.equals(pass)){
  15. System.out.println("\nIdentity confirmed.");
  16.  
  17. System.out.print("Enter product id (Type 'cancel' to return to menu): ");
  18. String id = input.nextLine();
  19.  
  20. System.out.print("Enter product name (Type 'cancel' to return to menu): ");
  21. String title = input.nextLine();
  22.  
  23. System.out.print("Enter product price (Type 'cancel' to return to menu): ");
  24. String price = input.nextLine();
  25.  
  26. if
  27.  
  28. if (id.equalsIgnoreCase("cancel") || title.equalsIgnoreCase("cancel") || price.equalsIgnoreCase("cancel")){
  29. System.out.println("Are you sure you want to cancel [Y/N]? ");
  30. String kensel = input.nextLine();
  31.  
  32. if (kensel.equalsIgnoreCase("y")){
  33. System.out.println("\nReturning to main menu...");
  34. add = false;
  35. break;
  36. } else {
  37. continue;
  38. }
  39. } else {
  40. productid.add(id);
  41. producttitle.add(title);
  42. productprice.add(price);
  43.  
  44. System.out.println("Item added.");
  45.  
  46. }
  47. break;
  48. } else if (j==4){
  49. System.out.println("Too many attempts made. Please contact administrator.\n");
  50.  
  51. boolean pleaselah = true;
  52. String username2;
  53. String password2;
  54.  
  55. while (pleaselah == true) {
  56. System.out.print("Please enter admin username: ");
  57. username2 = input.nextLine();
  58. System.out.print("Please enter admin password: ");
  59. password2 = input.nextLine();
  60.  
  61. MessageDigest adminhash = null;
  62.  
  63. try {
  64. adminhash = MessageDigest.getInstance("MD5");
  65. } catch(NoSuchAlgorithmException e){
  66.  
  67. }
  68.  
  69. adminhash.reset();
  70. adminhash.update(password2.getBytes());
  71. byte[] digest2 = adminhash.digest();
  72. BigInteger bigint2 = new BigInteger(1,digest2);
  73. String adminhashed = bigint2.toString(16);
  74. while(adminhashed.length() < 32 ){
  75. adminhashed = "0" + adminhashed;
  76. }
  77.  
  78. boolean enteradminid = adminnames.contains(username2);
  79. boolean enteradminpassword = adminpassword.contains(adminhashed);
  80.  
  81. if (enteradminid == true && enteradminpassword == true){
  82. j = -1;
  83. System.out.println("Administrator credentials accepted. Please re-enter salesperson credentials.\n");
  84. pleaselah = false;
  85. } else {
  86.  
  87. }//end if
  88. }//end for
  89. }//end if
  90. }//end for
  91. }//DO NOT TOUCH
  92.  
  93. break;
  94. //-----------update product=======================================
  95. case "3":
  96. boolean update = true;
  97.  
  98. while (update == true){
  99. for (int j = 0; j < 5; j++) {
  100. System.out.println("\nPlease re-enter password to confirm identity (Type 'cancel' to return to main menu): ");
  101. String confirmadd = input.nextLine();
  102.  
  103. if (confirmadd.equalsIgnoreCase("cancel")){
  104. System.out.println("\nReturning to main menu...");
  105. update = false;
  106. break;
  107. } else if (confirmadd.equals(pass)){
  108. System.out.println("\nIdentity confirmed.");
  109.  
  110. System.out.print("Enter product id (Type 'finish' to return to menu): ");
  111. String id = input.nextLine();
  112.  
  113. if (id.equalsIgnoreCase("finish")){
  114. System.out.println("\nReturning to main menu...");
  115. update = false;
  116. break;
  117. } else {
  118. boolean found = productid.contains(id);
  119.  
  120. if(found==true){
  121. int index = productid.indexOf(id);
  122. System.out.println("\nProduct ID found.\n");
  123. System.out.println("Product ID: " + productid.get(index));
  124. System.out.println("Product Title: " + producttitle.get(index));
  125. System.out.println("Product Price: " + productprice.get(index));
  126.  
  127. System.out.println("Which would you like to update?");
  128. System.out.println("1) Product ID");
  129. System.out.println("2) Product Title");
  130. System.out.println("3) Product Price");
  131. System.out.println("4) All of the above");
  132. System.out.print("Enter operation number: ");
  133. String produpdate = input.nextLine();
  134.  
  135. String newid = null;
  136. String newtitle = null;
  137. String newprice = null;
  138.  
  139. switch (produpdate){
  140. case "1":
  141. System.out.println("Enter updated product ID value: ");
  142. newid = input.nextLine();
  143. productid.set(index, newid);
  144.  
  145. System.out.println("\nItem updated.");
  146. break;
  147. case "2":
  148. System.out.println("Enter updated product title value: ");
  149. newtitle = input.nextLine();
  150.  
  151. producttitle.set(index, newtitle);
  152. System.out.println("\nItem updated.");
  153. break;
  154. case "3":
  155. System.out.println("Enter updated product price value: ");
  156. newprice = input.nextLine();
  157.  
  158. productprice.set(index, newprice);
  159. System.out.println("\nItem updated.");
  160. break;
  161. case "4":
  162. System.out.println("Enter updated product ID value: ");
  163. newid = input.nextLine();
  164. System.out.println("Enter updated product title value: ");
  165. newtitle = input.nextLine();
  166. System.out.println("Enter updated product price value: ");
  167. newprice = input.nextLine();
  168.  
  169. productid.set(index, newid);
  170. producttitle.set(index, newtitle);
  171. productprice.set(index, newprice);
  172. System.out.println("\nItem updated.");
  173. break;
  174. default:
  175. System.out.println("Operation "+menu+" does not exist.");
  176. break;
  177. }
  178. } else if (found == false){
  179. System.out.println("ID not found. Please re-enter product ID.");
  180. }
  181. }
  182. break;
  183. } else if (j==4){
  184. System.out.println("Too many attempts made. Please contact administrator.\n");
  185.  
  186. boolean pleaselah = true;
  187. String username2;
  188. String password2;
  189.  
  190. while (pleaselah == true) {
  191. System.out.print("Please enter admin username: ");
  192. username2 = input.nextLine();
  193. System.out.print("Please enter admin password: ");
  194. password2 = input.nextLine();
  195.  
  196. MessageDigest adminhash = null;
  197.  
  198. try {
  199. adminhash = MessageDigest.getInstance("MD5");
  200. } catch(NoSuchAlgorithmException e){
  201.  
  202. }
  203.  
  204. adminhash.reset();
  205. adminhash.update(password2.getBytes());
  206. byte[] digest2 = adminhash.digest();
  207. BigInteger bigint2 = new BigInteger(1,digest2);
  208. String adminhashed = bigint2.toString(16);
  209. while(adminhashed.length() < 32 ){
  210. adminhashed = "0" + adminhashed;
  211. }
  212.  
  213. boolean enteradminid = adminnames.contains(username2);
  214. boolean enteradminpassword = adminpassword.contains(adminhashed);
  215.  
  216. if (enteradminid == true && enteradminpassword == true){
  217. j = -1;
  218. System.out.println("Administrator credentials accepted. Please re-enter salesperson credentials.\n");
  219. pleaselah = false;
  220. } else {
  221.  
  222. }//end if
  223. }//end for
  224. }//end if
  225. }//end for
  226. }
  227.  
  228. break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement