Design Pattern Examples
Overview of object-oriented design patterns
Command_TextObject Class Reference

Container for a string. Need to use a class that allows the text to be changed while the container (this class) remains constant. This way, operations can be applied to the text and the container's contents change but not the container (strings are immutable in C#; this dances around that problem). More...

Collaboration diagram for Command_TextObject:
Collaboration graph

Public Member Functions

 Command_TextObject (string text)
 Constructs a text object with an initial string.
 
void Reset ()
 Resets the TextObject to the starting string.
 
override string ToString ()
 Converts the TextObject to a string.
 

Properties

string Text [get, set]
 Gets or sets the text in this TextObject.
 

Private Attributes

string _startingText
 
string _text
 

Detailed Description

Container for a string. Need to use a class that allows the text to be changed while the container (this class) remains constant. This way, operations can be applied to the text and the container's contents change but not the container (strings are immutable in C#; this dances around that problem).

Definition at line 18 of file Command.cs.

Constructor & Destructor Documentation

◆ Command_TextObject()

Command_TextObject ( string  text)
inline

Constructs a text object with an initial string.

Parameters
textThe initial string for the text object.

Definition at line 30 of file Command.cs.

References Command_TextObject._startingText, and Command_TextObject._text.

Member Function Documentation

◆ Reset()

void Reset ( )
inline

Resets the TextObject to the starting string.

Definition at line 54 of file Command.cs.

References Command_TextObject._startingText, and Command_TextObject._text.

Referenced by Command_Exercise.Command_Undo().

◆ ToString()

override string ToString ( )
inline

Converts the TextObject to a string.

Returns
Returns the text stored in the text object.

Definition at line 64 of file Command.cs.

References Command_TextObject._text.

Member Data Documentation

◆ _startingText

string _startingText
private

Definition at line 21 of file Command.cs.

Referenced by Command_TextObject.Command_TextObject(), and Command_TextObject.Reset().

◆ _text

Property Documentation

◆ Text

string Text
getset

Gets or sets the text in this TextObject.

Definition at line 39 of file Command.cs.

Referenced by Command_Exercise.Command_Operation_Replace(), and Command_Exercise.Command_Operation_Reverse().


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