Class PrintDescending

java.lang.Object
commandManagers.Command
commandManagers.commands.PrintDescending
All Implemented Interfaces:
CommandInterface

public class PrintDescending extends Command
The PrintDescending class is a command class that prints the population of all cities in descending order. It extends the abstract class Command.
  • Constructor Details

    • PrintDescending

      public PrintDescending()
  • Method Details

    • getName

      public String getName()
      Description copied from class: Command
      Base method for show command name
      Specified by:
      getName in interface CommandInterface
      Specified by:
      getName in class Command
      Returns:
      command name
    • getDescr

      public String getDescr()
      Description copied from class: Command
      Base method for show command description.
      Specified by:
      getDescr in interface CommandInterface
      Specified by:
      getDescr in class Command
      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 interface CommandInterface
      Specified by:
      execute in class Command
    • checkArgument

      public boolean checkArgument(Object inputArgument)
      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 interface CommandInterface
      Specified by:
      checkArgument in class Command
      Parameters:
      inputArgument - the argument to be checked
      Returns:
      true if the argument is null, false otherwise