monthendcommand.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 37 行

JAVA
37
字号
package Commands;

import Interfaces.*;
import Sets.AccountSetAccess;
import SystemEntities.Printer;
import Accounts.Account;

/**	The command to print out all month end statements */
public class MonthEndCommand extends Command
{
	/**	The interface that is to be used by this command */
	AdminInterface cmdInterface;
	
	/**	The constructor for this command */
	public MonthEndCommand(StaffInterface userInterface)
	{
		if (userInterface instanceof AdminInterface)	
			cmdInterface = (AdminInterface) userInterface;
		else
			userInterface.sendMessage("You are not allowed to print the month end statement.");
	}

	/**	Execute the command */
	public void execute()
	{
		if (cmdInterface != null)
		{
			AccountSetAccess.dictionary().goFirst();
			while (!AccountSetAccess.dictionary().after())
			{
				Printer.printStmt(((Account)AccountSetAccess.dictionary().item()).generateMonthlyStmt());
				AccountSetAccess.dictionary().goForth();
			}
		}
	}
}

⌨️ 快捷键说明

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