O'Reilly logo

Microsoft®C# Programming for the absolute beginner by Andy Harris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making the Critter More Lifelike

You now know all you need to know to make the critter a lot of fun. By adding a few more variables, properties, and methods, you can re-create the critter featured at the beginning of this chapter. Remember that my original algorithm was to have a critter whose moods change according to the way it is treated. I wanted to achieve this effect as easily as possible.

Adding More Private Variables

I added a couple private variables to the critter, but not to make them properties (at least, not yet), because I wanted the user to interact with them indirectly. Here’s the list of private variables and properties for the final Critter class:

 class Critter { private string pName; private int pFull = 10; private int pHappy ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required