One-Class Phonebook

The one class version of phone book is essentially a procedural program (a collection of methods that call one another) placed inside a Java class. It uses the KeyboardInput, FileInput and FileOutput classes (copies of these should be placed in the same directory as OneClassPhoneBook in order to compile and run it).

This is the class:

import java.util.ArrayList;
public class OneClassPhoneBook
{
  private KeyboardInput in = new KeyboardInput();
  private ArrayList names = new ArrayList();
  private ArrayList numbers = new ArrayList();
  public void go()
  {
    boolean quit = false;
    while (!quit)
    {
      displayMenu();
      int item = in.readInteger();
      quit = doAction(item);
    }
  }
  private boolean doAction(int item)
  {
    switch (item)
    {
      case 1 :
        searchForEntry();
        break;
      case 2 :
        addEntry();
        break;
      case 3 :
        removeEntry();
        break;
      case 4 :
        saveList();
        break;
      case 5 :
        loadList();
        break;
      case 6 :
        return true;
      default :
        System.out.println("\nSorry - don't recognise that item, try again");
    }
    return false;
  }
  private void displayMenu()
  {
    System.out.println("\nPhone Book");
    System.out.println("1. Search for a person's phone number");
    System.out.println("2. Add a new person and phone number");
    System.out.println("3. Remove a person and phone number");
    System.out.println("4. Save phone list to a file");
    System.out.println("5. Add a phone list from a file");
    System.out.println("6. Quit");
    System.out.print("\nSelect an item from the menu: ");
  }
  public void addEntry()
  {
    System.out.println("\nAdd entry to phone list");
    System.out.print("Enter the person's name: ");
    String name = in.readString();
    System.out.print("Enter the person's phone number: ");
    String phone = in.readString();
    names.add(name);
    numbers.add(phone);
  }
  private void remove(String name)
  {
    for (int i = 0; i < names.size(); i++)
    {
      String entry = (String) names.get(i);
      if (entry.equals(name))
      {
        names.remove(i);
        numbers.remove(i);
        return;
      }
    }
    System.out.println("Name not found - nothing removed");
  }
  public void removeEntry()
  {
    System.out.println("\nRemove entry from phone list");
    System.out.print("Enter the person's name: ");
    String name = in.readString();
    remove(name);
  }
  private String getPhoneNumber(String name)
  {
    for (int i = 0; i < names.size(); i++)
    {
      String entry = (String) names.get(i);
      if (entry.equals(name))
      {
        return (String) numbers.get(i);
      }
    }
    // No match found.
    return "";
  }
  public void searchForEntry()
  {
    System.out.println("\nSearch phone list");
    System.out.print("Enter the person's name: ");
    String name = in.readString();
    String phone = getPhoneNumber(name);
    if (phone.equals(""))
    {
      System.out.println("Sorry - nothing found");
    }
    else
    {
      System.out.println("The phone number is: " + phone);
    }
  }
  private void writeToFile(FileOutput file)
  {
    for (int i = 0; i < names.size(); i++)
    {
      file.writeString((String) names.get(i));
      file.writeNewline();
      file.writeString((String) numbers.get(i));
      file.writeNewline();
    }
  }
  public void saveList()
  {
    System.out.println("\nSave phone list to a file");
    System.out.print("Enter the file name: ");
    String fileName = in.readString();
    FileOutput out = new FileOutput(fileName);
    writeToFile(out);
    out.close();
  }
  private void readFromFile(FileInput file)
  {
    String name = file.readString();
    String phone = file.readString();
    while (!file.eof())
    {
      names.add(name);
      numbers.add(phone);
      name = file.readString();
      phone = file.readString();
    }
  }
  public void loadList()
  {
    System.out.println("\nAppend phone list from a file");
    System.out.print("Enter the file name: ");
    String fileName = in.readString();
    FileInput fileIn = new FileInput(fileName);
    readFromFile(fileIn);
    fileIn.close();
  }
  public static void main(String[] args)
  {
    OneClassPhoneBook phoneBook = new OneClassPhoneBook();
    phoneBook.go();
  }
}