From the course: Object-Oriented Programming with C#

Unlock the full course today

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

Use action

Use action

- [Instructor] The last thing we need to add to our game is a way to use the key with the chest. Before we do that, let's go ahead and add the properties we need, in the language and English classes. We'll create a use property, a use success property, and a use error property. In our English class, we'll give each of these properties a value. We'll set the use property to a string, use, we'll set the use success to a string template, you use the with a single token, and the use error to, you can't use that. Now let's go ahead and create a use class in our actions folder. Once you've created your name space, go ahead and create a public class called use, and have it extend the action class. Just like before, we're going to need a reference to the house, so let's create a private, read-only field. Next, we'll create a constructor, so that we can save a reference to the house that gets passed in, when we make a new…

Contents