Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package UI;
- import Phonebook.Phonebook;
- import java.util.Scanner;
- public class UserInterface {
- private Scanner read;
- public UserInterface() {
- this.read = new Scanner(System.in);
- }
- public void Start() {
- Phonebook phoneBook = new Phonebook();
- commandList();
- enterCommand(phoneBook);
- }
- public void enterCommand(Phonebook book) {
- while (true) {
- System.out.print("command: ");
- String command = read.nextLine();
- if (command.equals("x")) {
- break;
- } else if (command.equals("1")) {
- System.out.print("whose number: ");
- String whose = read.nextLine();
- System.out.print("number: ");
- String number = read.nextLine();
- book.addNumber(whose, number);
- } else if (command.equals("2")) {
- System.out.println("whose number: ");
- String whose = read.nextLine();
- book.printNumbers(whose);
- } else if (command.equals("3")) {
- } else if (command.equals("4")) {
- System.out.print("whose address: ");
- String whose = read.nextLine();
- System.out.println("street: ");
- String street = read.nextLine();
- System.out.println("city: ");
- String city = read.nextLine();
- book.addAddress(whose, street, city);
- } else if (command.equals("5")) {
- } else if (command.equals("6")) {
- } else if (command.equals("7")) {
- }
- }
- }
- public void commandList() {
- System.out.println("phone search");
- System.out.println("available operations:");
- System.out.println(" 1 add a number");
- System.out.println(" 2 search for a number");
- System.out.println(" 3 search for a person by phone number");
- System.out.println(" 4 add an address");
- System.out.println(" 5 search for personal information");
- System.out.println(" 6 delete personal information");
- System.out.println(" 7 filtered listing");
- System.out.println(" x quit");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement