1  import java.util.ArrayList;
  2  import java.util.Scanner;
  3  
  4  /**
  5     A menu that is displayed on a console.
  6  */
  7  public class Menu
  8  {
  9     private String menuText;
 10     private int optionCount;
 11  
 12     /**
 13        Constructs a menu with no options.
 14     */
 15     public Menu()
 16     {
 17        menuText = "";
 18        optionCount = 0;
 19     }
 20  
 21     /**
 22        Adds an option to the end of this menu.
 23        @param option the option to add
 24     */
 25     public void addOption(String option)
 26     {
 27        optionCount = optionCount + 1;
 28        menuText = menuText + optionCount + ") " + option + "\n";
 29     }
 30     
 31     /**
 32        Displays the menu on the console.
 33     */
 34     public void display()
 35     {
 36        System.out.println(menuText);
 37     }
 38  }
 39  
 40