我创建了一个注册表类,用于向注册表添加和删除学生,还包含一个学生类。现在我必须构建一个带有主菜单的界面,其中有 4 个选项可供选择,包括:添加学生、删除学生、打印注册表并退出。扫描仪将用于破译用户选择的选项。
我真的不知道如何创建这个,我得到了一个模板来填写,但我无法理解它。此外,由于我的 RegistryInterface 没有 main 方法,因此我必须创建一个 RegistryApp,我也有一个模板。
任何有关如何创建它的帮助/建议将不胜感激,我对界面构建完全陌生,抱歉!
RegistryInterface代码模板:
import java.util.*;
public class RegistryInterface {
private Registry theRegistry = null;
public RegistryInterface(Registry theRegistry){}
//Displays the main menu and gets valid option from user
public void doMenu()
{
System.out.println("Registry Main Menu");
System.out.println("****************** \n");
System.out.println("1. Add a Student");
System.out.println("2. Delete a Student");
System.out.println("3. Print Registry");
System.out.println("4. Quit");
System.out.println("Select option [1, 2, 3, 4] :>");
}
private void doAddStudent() {}
private void doDeleteStudent() {}
private void doPrintRegistry() {}
}
RegistryApp 代码模板:
public class RegistryApp {
public static void main (String[] args)
{
//Create the registry object
Registry theRegistry = new Registry();
//Create an interface
RegistryInterface aRegistryInterface
= new RegistryInterface (theRegistry);
//Display the menu
aRegistryInterface.doMenu();
}
}