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 TypeMethodDescriptionboolean
checkArgument
(Object inputArgument) Checks whether the PrintDescending command has an argument.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.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:Command
Base method for show command name- Specified by:
getName
in interfaceCommandInterface
- Specified by:
getName
in classCommand
- Returns:
- command name
-
getDescr
Description copied from class:Command
Base method for show command description.- Specified by:
getDescr
in interfaceCommandInterface
- Specified by:
getDescr
in 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:
execute
in interfaceCommandInterface
- Specified by:
execute
in 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:
checkArgument
in interfaceCommandInterface
- Specified by:
checkArgument
in classCommand
- Parameters:
inputArgument
- the argument to be checked- Returns:
- true if the argument is null, false otherwise
-