creation 4/17/99; revisions: 09/06/99, 09/12/99, 01/21/00

CHAPTER 31 --- Designing a Class (Miles per Gallon)

This chapter contains another example of designing a class, and then using objects of that type. The class will be named Car, and will be a simplified version of a miles-per-gallon calculator.

Like the HelloObject class of the previous chapter, the Car class will be simple, so that you can concentrate on the ideas of object oriented programming.

Chapter Topics:

  • How classes are documented.
  • Writing a class definition.
  • Instance variables.
  • Using instance variables in a method.
  • Constructors.
  • Constructor parameter lists.

QUESTION 1:

What three values are you likely to use in calculating miles per gallon for a car?

Click Here after you have answered the question