001package myproject.ui;
002
003/**
004 * @see UIMenuBuilder
005 */
006public final class UIMenu {
007        private final String heading;
008        private final Pair[] menu;
009
010        static final class Pair {
011                final String prompt;
012                final UIMenuAction action;
013
014                Pair(String prompt, UIMenuAction action) {
015                        this.prompt = prompt;
016                        this.action = action;
017                }
018        }
019
020        UIMenu(String heading, Pair[] menu) {
021                this.heading = heading;
022                this.menu = menu;
023        }
024        public int size() {
025                return menu.length;
026        }
027        public String getHeading() {
028                return heading;
029        }
030        public String getPrompt(int i) {
031                return menu[i].prompt;
032        }
033        public void runAction(int i) {
034                menu[i].action.run();
035        }
036}