Design Pattern Examples
Overview of object-oriented design patterns
MoveCommand Class Referenceabstract

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...

Inheritance diagram for MoveCommand:
Inheritance graph
Collaboration diagram for MoveCommand:
Collaboration graph

Public Member Functions

 MoveCommand (string command, string commandName)
 Constructor.
 
void Show ()
 Display the move command and its name followed by a newline.
 
abstract void Execute ()
 Execute the command. Derived classes must implement this.
 

Properties

string Name [get, private set]
 Name of the command (assigned in the class constructor).
 
string Command [get, private set]
 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).
 

Detailed Description

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 24 of file Null_Object.cs.

Constructor & Destructor Documentation

◆ MoveCommand()

MoveCommand ( string  command,
string  commandName 
)
inline

Constructor.

Parameters
commandThe character that represents the command in the original move list.
commandNameThe name of the command (for display purposes).

Definition at line 44 of file Null_Object.cs.

References MoveCommand.Name.

Member Function Documentation

◆ Execute()

abstract void Execute ( )
pure virtual

Execute the command. Derived classes must implement this.

Implemented in MoveCommandLeft, MoveCommandRight, MoveCommandUp, MoveCommandDown, and MoveCommandNone.

◆ Show()

void Show ( )
inline

Display the move command and its name followed by a newline.

Definition at line 54 of file Null_Object.cs.

References MoveCommand.Name.

Property Documentation

◆ Command

string Command
getprivate set

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 36 of file Null_Object.cs.

◆ Name

string Name
getprivate set

Name of the command (assigned in the class constructor).

Definition at line 29 of file Null_Object.cs.

Referenced by MoveCommand.MoveCommand(), Visitor_Shop.PickupOrder(), Visitor_Shop.PlaceOrder(), MoveCommand.Show(), and EntryInformation.ToString().


The documentation for this class was generated from the following file: