⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 controller.java

📁 国外的数据结构与算法分析用书
💻 JAVA
字号:
import Interfaces.StaffInterface;
import Commands.*;

/**	Class to obtain and handle a sequence of user commands. */
public class Controller
{

	/** 	Start the main control loop for a user; get  
		and execute a set of user commands. */
	public void initiate(StaffInterface userInterface)
	{
		int cmdID = userInterface.getCmdID();
		while(cmdID != 99)
		{
			handle(cmdID, userInterface);
			cmdID = userInterface.getCmdID();
		}
	}

	/**	Handle the command ID by executing the appropriate 
		command using the given user interface. */
	public void handle(int cmdID, StaffInterface userInterface)
	{
		Command currentCommand = null;
		switch(cmdID)
		{
			case 11:
				currentCommand = new BalanceCommand(userInterface);
				break;
			case 12:
				currentCommand = new DepositCommand(userInterface);
				break;
			case 21:
				currentCommand = new ChangeLocCommand(userInterface);
				break;
			case 22:
				currentCommand = new MonthEndCommand(userInterface);
				break;
		}
		if(currentCommand != null)
		{
			System.out.println("The command being executed is " + currentCommand.getClass().getName());
			currentCommand.execute();
		}
		else
			userInterface.sendMessage("****Illegal command number (" + cmdID + ") entered.  "
							+ "Please try again.");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -