Changing the Menu to Use the talk() Method

Because the Critter class now has a talk() method, the main program can invoke myCritter.talk() to hear from the critter. Examine how I changed the code in the main() method to take advantage of the critter’s newfound verbal skills:

case 1:
  myCritter.talk();
  break;

I didn’t change anything else in the program. You might notice that the main program becomes a little simpler as some of the functionality is shuffled off to the object. In object-oriented programming, as much detail as possible is handled by objects rather than by the main program.

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

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