Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5.  
  6. ArrayDirectory arraydirectory = new ArrayDirectory();
  7.  
  8. System.out.println("Choose an option from the menu: " + "\n" +
  9. "1. Array Directory" + "\n" +
  10. "2. ArrayListDirectory" + "\n" +
  11. "3. HashMapDirectory");
  12.  
  13. Scanner input = new Scanner(System.in);
  14.  
  15. int choice = input.nextInt();
  16.  
  17. if (choice == 1) {
  18. System.out.println("ArrayDirectory Menu:" + "\n" +
  19. "1. Insert New Entry" + "\n" +
  20. "2. Delete Entry Using Name" + "\n" +
  21. "3. Delete Entry Using Extension" + "\n" +
  22. "4. Update Extensions Using Name" + "\n" +
  23. "5. Display Entire Directory ");
  24. choice = input.nextInt();
  25. if (choice == 1 ){
  26. System.out.println("Enter Surname: ");
  27. String name = input.nextLine();
  28. System.out.println("Enter Initials: ");
  29. String initials1 = input.nextLine();
  30. System.out.println("Enter Extension: ");
  31. String number1 = input.nextLine();
  32. if (number1.length() == 5 ){
  33. arraydirectory.insertEntry(new Entry(name, initials1, number1));
  34. }
  35. else{
  36. System.out.println("System Ending...");
  37. }
  38.  
  39.  
  40. }
  41. else if(choice == 2){
  42. Scanner input1 = new Scanner(System.in);
  43. System.out.println("Enter Surname To Delete: ");
  44. String name = input1.nextLine();
  45. arraydirectory.deleteEntryUsingName(name);
  46. }
  47.  
  48. else if (choice == 3){
  49. System.out.println("Enter Extension Number To Delete: ");
  50. String number1 = input.nextLine();
  51. arraydirectory.deleteEntryUsingExtension(number1);
  52. }
  53.  
  54. else if (choice == 4){
  55. System.out.println("Enter Name Of Employee that You Would Like To Update: ");
  56. String name = input.nextLine();
  57. System.out.println("Enter The New Extension Number: ");
  58. String newNumber = input.nextLine();
  59. arraydirectory.updateExtensionUsingName(name, newNumber);
  60. }
  61.  
  62. else if (choice == 5 ){
  63. System.out.println("Enter Name Of Employee that You Would Like To See: ");
  64. String name = input.nextLine();
  65. arraydirectory.lookupExtension(name);
  66. }
  67. }
  68.  
  69. else if (choice == 2) {
  70. System.out.println("ArrayList Menu:" + "\n" +
  71. "1. Insert New Entry" + "\n" +
  72. "2. Delete Entry Using Name" + "\n" +
  73. "3. Delete Entry Using Extension" + "\n" +
  74. "4. Update Extensions Using Name" + "\n" +
  75. "5. Display Entire Directory ");
  76. }
  77.  
  78. else if (choice == 3) {
  79. System.out.println("HashMap Menu:" + "\n" +
  80. "1. Insert New Entry" + "\n" +
  81. "2. Delete Entry Using Name" + "\n" +
  82. "3. Delete Entry Using Extension" + "\n" +
  83. "4. Update Extensions Using Name" + "\n" +
  84. "5. Display Entire Directory ");
  85.  
  86.  
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement