Class AddIfMin

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

public class AddIfMin extends Command
Command to add a new city to the collection if it has a smaller population than the smallest city in the collection.
Author:
boris
  • Constructor Details

    • AddIfMin

      public AddIfMin()
      Default constructor from 1.0
    • AddIfMin

      public AddIfMin(ModeManager<City> handler)
      Provides choosing handler
      Parameters:
      handler - ModuleHandler for operating
      Since:
      2.0
  • 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() throws BuildObjectException
      Adds a new city to the collection if its population is less than the population of the smallest city in the collection. Prints a message indicating that the command does not take arguments if an argument is provided.
      Specified by:
      execute in interface CommandInterface
      Specified by:
      execute in class Command
      Throws:
      BuildObjectException
    • checkArgument

      public boolean checkArgument(Object inputArgument)
      Checks whether an argument is provided or not.
      Specified by:
      checkArgument in interface CommandInterface
      Specified by:
      checkArgument in class Command
      Parameters:
      inputArgument - the argument to be checked.
      Returns:
      true if no argument is provided and false otherwise.