我创建了一个Registry类,用于添加和删除学生到寄存器,也包含Student类。现在我必须构建一个带有主菜单的界面,其中有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();
}
}
答案 0 :(得分:0)
您的RegistryInterface
是一个类,而不是一个接口
public interface
RegistryImpl
)RegistryInterface RI = new RegistryInterface(R);
)答案 1 :(得分:0)
这样的事情可能有所帮助:
public interface RegistryInterface {
//Displays the main menu and gets valid option from user
public void doMenu();
public void doAddStudent();
public void doDeleteStudent();
public void doPrintRegistry();
}
注册表:
public class Registy implements RegistryInterface {
//java will force you to write methods the same as the ones declared in
//RegistryInterface...
}
主要课程:
public static void main (String[] args)
{
//Create the registry object
RegistryInterface theRegistry = new Registry();
//Display the menu
theRegistry.doMenu();
//etc...
}
答案 2 :(得分:-1)
您似乎在谈论图形用户界面,如果您对Java GUI完全陌生,那么http://docs.oracle.com/javase/tutorial/uiswing/上有一个非常精细的教程