Package commandManagers
Class Command
java.lang.Object
commandManagers.Command
- All Implemented Interfaces:
CommandInterface
- Direct Known Subclasses:
Add
,AddIfMin
,Clear
,ExecuteScript
,Exit
,Help
,History
,Info
,PrintDescending
,PrintFieldDescendingMetersAboveSeaLevel
,RemoveById
,RemoveGreater
,Save
,Show
,SumOfMetersAboveSeaLevel
,UpdateId
Abstract class representing a command that can be executed in the program.
-
Constructor Summary
ConstructorsConstructorDescriptionCommand
(boolean hasArgument) Constructs a new command with the specified argument requirement. -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
checkArgument
(Object inputArgument) Checks if the given inputArgument is valid for this command.abstract void
execute()
Executes command.Returns the argument for this command.abstract String
getDescr()
Base method for show command description.abstract String
getName()
Base method for show command nameboolean
Returns whether this command requires an argument.void
setArgument
(String argument) Sets the argument for this command.
-
Constructor Details
-
Command
public Command(boolean hasArgument) Constructs a new command with the specified argument requirement.- Parameters:
hasArgument
- a boolean indicating whether this command requires an argument or not.
-
-
Method Details
-
getName
Base method for show command name- Specified by:
getName
in interfaceCommandInterface
- Returns:
- command name
-
getDescr
Base method for show command description.- Specified by:
getDescr
in interfaceCommandInterface
- Returns:
- command description
-
execute
Executes command.- Specified by:
execute
in interfaceCommandInterface
- Throws:
BuildObjectException
-
checkArgument
Checks if the given inputArgument is valid for this command.- Specified by:
checkArgument
in interfaceCommandInterface
- Parameters:
inputArgument
- the argument to check.- Returns:
- true if the argument is valid, false otherwise.
-
isHasArgument
public boolean isHasArgument()Returns whether this command requires an argument.- Returns:
- true if this command requires an argument, false otherwise.
-
getArgument
Returns the argument for this command.- Returns:
- the argument for this command.
-
setArgument
Sets the argument for this command.- Parameters:
argument
- the argument to set.
-