Chapter 4. Objects and Encapsulation: The Critter Program

You have learned most of the critical aspects of programming a computer. From now on, you will be learning variations of these basic skills. To help you manage the complexity of larger programs, C# uses an important programming paradigm called object-oriented programming (OOP). You are already slightly familiar with object orientation because you’ve been using objects that come with the .NET environment, such as the string object, convert object, and console object. However, you will discover the real power of OOP when you create objects of your own. In a nutshell, object-oriented programming enables you to combine the information and instructions of your programs into objects. The objects you have already used feature properties, which encapsulate the data in a program, and methods, which house the instructions in a program. You will learn how to build your own objects with these properties and methods. After reading this chapter you will be able to

  • Create your own objects.

  • Add methods to your program.

  • Communicate to and from your methods.

  • Build a classic console-based menu system.

  • Trap for certain kinds of errors.

  • Create your own custom object.

  • Add methods and properties to your object.

  • Understand how basic scope modifiers work.

  • Use properties to improve the reliability of your object.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.241.250