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