Base class that represents a move command. A move command has a name and the command character that represents the command in the initial string of movement commands. More...
#include <Null_Object.h>
Public Types | |
using | shared_ptr_t = std::shared_ptr< MoveCommand > |
Alias to make it easier to work with a shared pointer. | |
Public Member Functions | |
virtual | ~MoveCommand () |
Virtual destructor required for interfaces/base classes. | |
std::string | Name () |
Name of the command (assigned in the class constructor). | |
std::string | Command () |
The command character from the original list of commands. Used when displaying the commands as opposed to when executing the commands (assigned in the class constructor). | |
MoveCommand (std::string command, std::string commandName) | |
Constructor. | |
virtual void | Show () |
Display the move command and its name followed by a newline. | |
virtual void | Execute ()=0 |
Execute the command. Derived classes must implement this. | |
Private Attributes | |
std::string | _name |
Name of the command. | |
std::string | _command |
The command for controlling movement. | |
Base class that represents a move command. A move command has a name and the command character that represents the command in the initial string of movement commands.
Yes, this is a variation of the Command Pattern.
In this example, a move command, when executed, prints "move xxx" on the current line. When displayed, the move command shows the command character followed by the name of the command.
Definition at line 32 of file Null_Object.h.
using shared_ptr_t = std::shared_ptr<MoveCommand> |
Alias to make it easier to work with a shared pointer.
Definition at line 38 of file Null_Object.h.
|
inlinevirtual |
Virtual destructor required for interfaces/base classes.
Definition at line 55 of file Null_Object.h.
|
inline |
Constructor.
command | The character that represents the command in the original move list. |
commandName | The name of the command (for display purposes). |
Definition at line 81 of file Null_Object.h.
|
inline |
The command character from the original list of commands. Used when displaying the commands as opposed to when executing the commands (assigned in the class constructor).
Definition at line 70 of file Null_Object.h.
References MoveCommand::_command.
|
pure virtual |
Execute the command. Derived classes must implement this.
Implemented in MoveCommandLeft, MoveCommandRight, MoveCommandUp, MoveCommandDown, and MoveCommandNone.
|
inline |
Name of the command (assigned in the class constructor).
Definition at line 60 of file Null_Object.h.
References MoveCommand::_name.
Referenced by Visitor_Shop::PickupOrder(), Visitor_Shop::PlaceOrder(), and EntryInformation::ToString().
|
inlinevirtual |
Display the move command and its name followed by a newline.
Definition at line 91 of file Null_Object.h.
References MoveCommand::_command, MoveCommand::_name, and Helpers::formatstring().
|
private |
The command for controlling movement.
Definition at line 49 of file Null_Object.h.
Referenced by MoveCommand::Command(), and MoveCommand::Show().
|
private |
Name of the command.
Definition at line 44 of file Null_Object.h.
Referenced by User::__eq__(), Visitor_Village::LoadVillage(), MoveCommand::Name(), FileDirEntry::Name(), User::Name(), Memento_TextObject.Memento::Name(), Visitor_Village::Name(), and MoveCommand::Show().