From the course: Object-Oriented Programming with C#

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Actions

Actions

- [Instructor] We're going to use a new design pattern called the command pattern. In the command pattern, we use classes to execute a single command. You might be used to this in any program that has undo and redo. Every action you perform is a command that is placed into a stack and the user can traverse it to move forward or backwards through history. The beauty of the command pattern is that each command instance has all the logic and state it needs to execute. So it's self-contained and not dependent on any other logic. To get started, let's create a new folder called Actions. And we'll create an abstract action inside of it. Now that we have our name space, let's create our abstract class action. Each action inside of our game is going to have a unique identifier called the name. We're going to create a property for the name and we're going to mark it as virtual. Which tells the compiler that other classes that…

Contents