10from abc
import ABC, abstractmethod
29 def __init__(self, command : str, commandName : str) ->
None:
67 print(
"move left", end=
"")
86 print(
"move right", end=
"")
105 print(
"move up", end=
"")
124 print(
"move down", end=
"")
182 for index
in range(0, len(moveList)):
183 commandChar = moveList[index].upper()
203 commands.append(moveCommand);
222 for command
in commands:
235 for command
in commands:
Represents the Move Down command.
None __init__(self, str command)
Constructor.
None Execute(self)
Executes the move down command.
Base class that represents a move command.
None Show(self)
Display the move command and its name followed by a newline.
None Execute(self)
Execute the command.
_name
Name of the command.
None __init__(self, str command, str commandName)
Constructor.
_command
The command for controlling movement.
Represents the Move Left command.
None __init__(self, str command)
Constructor.
None Execute(self)
Executes the move left command.
Represents the Do Nothing command.
None __init__(self, str command)
Constructor.
str Execute(self)
Does nothing when executed (this is the Null Object, after all).
Represents the Move Right command.
def Execute(self)
Executes the move right command.
None __init__(self, str command)
Constructor.
Represents the Move Up command.
None Execute(self)
Executes the move up command.
None __init__(self, str command)
Constructor.
None ShowMoveList(self, str moveList)
Parse and display the given list of move commands, where each command is represents by a single chara...
list[MoveCommand] _ParseMoves(self, str moveList)
Helper method to convert a list of single letter commands into a list of MoveCommand objects.
None _ShowMoves(self, list[MoveCommand] commands)
Display the command character and name of the command for each command in the given list of commands.
None ExecuteMoveList(self, str moveList)
Parse and execute the given list of move commands, where each command is represents by a single chara...
None _ExecuteMoves(self, list[MoveCommand] commands)
Helper method to execute all the given commands.
Represents a move command. A move command has a name and the command character that represents the co...