📄 menu.java
字号:
public class Menu
{
private String title;
private String choices[] = null;
private MenuUser user = null;
public Menu(String _title, String _choices[], MenuUser _user)
{
title = _title;
choices = _choices;
user = _user;
start();
}
private String getMenuChoice()
{
System.out.println("\n\t" + title + "\n");
for (int i = 0; i < choices.length; i++)
{
System.out.println("\t" + choices[i]);
}
System.out.println("\n\tType 'Exit' to exit the menu");
System.out.print("\n\tEnter your choice: ");
return Console.readString();
}
private void start()
{
String choice = getMenuChoice();
while (!choice.equalsIgnoreCase("exit"))
{
user.performAction(choice);
choice = getMenuChoice();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -