Package commandManagers.commands
Class PrintDescending
java.lang.Object
commandManagers.Command
commandManagers.commands.PrintDescending
- All Implemented Interfaces:
CommandInterface
The PrintDescending class is a command class that prints the population of all cities
in descending order. It extends the abstract class Command.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckArgument(Object inputArgument) Checks whether the PrintDescending command has an argument.voidexecute()Executes the PrintDescending command by first checking if it has an argument, then retrieving the collection of cities and creating an ArrayList of cities.getDescr()Base method for show command description.getName()Base method for show command nameMethods inherited from class commandManagers.Command
getArgument, isHasArgument, setArgument
-
Constructor Details
-
PrintDescending
public PrintDescending()
-
-
Method Details
-
getName
Description copied from class:CommandBase method for show command name- Specified by:
getNamein interfaceCommandInterface- Specified by:
getNamein classCommand- Returns:
- command name
-
getDescr
Description copied from class:CommandBase method for show command description.- Specified by:
getDescrin interfaceCommandInterface- Specified by:
getDescrin classCommand- Returns:
- command description
-
execute
public void execute()Executes the PrintDescending command by first checking if it has an argument, then retrieving the collection of cities and creating an ArrayList of cities. The ArrayList is then reversed and the population of each city is printed in descending order.- Specified by:
executein interfaceCommandInterface- Specified by:
executein classCommand
-
checkArgument
Checks whether the PrintDescending command has an argument. Since this command does not require an argument, it will return true if inputArgument is null.- Specified by:
checkArgumentin interfaceCommandInterface- Specified by:
checkArgumentin classCommand- Parameters:
inputArgument- the argument to be checked- Returns:
- true if the argument is null, false otherwise
-