Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. package UI;
  2.  
  3. import Phonebook.Phonebook;
  4. import java.util.Scanner;
  5.  
  6. public class UserInterface {
  7.  
  8. private Scanner read;
  9.  
  10. public UserInterface() {
  11. this.read = new Scanner(System.in);
  12. }
  13.  
  14. public void Start() {
  15. Phonebook phoneBook = new Phonebook();
  16.  
  17. commandList();
  18. enterCommand(phoneBook);
  19. }
  20.  
  21. public void enterCommand(Phonebook book) {
  22. while (true) {
  23. System.out.print("command: ");
  24. String command = read.nextLine();
  25.  
  26. if (command.equals("x")) {
  27. break;
  28. } else if (command.equals("1")) {
  29. System.out.print("whose number: ");
  30. String whose = read.nextLine();
  31.  
  32. System.out.print("number: ");
  33. String number = read.nextLine();
  34.  
  35. book.addNumber(whose, number);
  36. } else if (command.equals("2")) {
  37. System.out.println("whose number: ");
  38. String whose = read.nextLine();
  39.  
  40. book.printNumbers(whose);
  41. } else if (command.equals("3")) {
  42.  
  43. } else if (command.equals("4")) {
  44. System.out.print("whose address: ");
  45. String whose = read.nextLine();
  46.  
  47. System.out.println("street: ");
  48. String street = read.nextLine();
  49.  
  50. System.out.println("city: ");
  51. String city = read.nextLine();
  52.  
  53. book.addAddress(whose, street, city);
  54. } else if (command.equals("5")) {
  55.  
  56. } else if (command.equals("6")) {
  57.  
  58. } else if (command.equals("7")) {
  59.  
  60. }
  61. }
  62. }
  63.  
  64. public void commandList() {
  65. System.out.println("phone search");
  66. System.out.println("available operations:");
  67. System.out.println(" 1 add a number");
  68. System.out.println(" 2 search for a number");
  69. System.out.println(" 3 search for a person by phone number");
  70. System.out.println(" 4 add an address");
  71. System.out.println(" 5 search for personal information");
  72. System.out.println(" 6 delete personal information");
  73. System.out.println(" 7 filtered listing");
  74. System.out.println(" x quit");
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement