go to previous page   go to home page   go to next page

Answer:

Yes. The rim, for instance, is made of yet smaller parts.


Class Car

Part of the skill of object oriented programming is in designing the right software objects to match the real world objects of the problem, and in deciding when to quit. It would (usually) make little sense to continue analyzing the bicycle until you were looking at atoms. On the other hand, sometimes very fine detail is desirable.

A good flight simulator program (for example) is realistic because its airplane objects are built up from many small objects. A crude simulation uses fewer objects.

Look at the definition for Car from a few chapters ago:


class Car
{
  // data
  int startMiles;   // Starting odometer reading
  int endMiles;     // Ending   odometer reading
  double gallons;   // Gallons of gas used between the readings

  // constructor
  Car(  int first, int last, double gals  )
  {
    startMiles = first ;
    endMiles   = last ;
    gallons    = gals ;
  }

  // methods
  double calculateMPG()
  {
    return (endMiles - startMiles)/gallons ;
  }

}

QUESTION 2:

Is the Car class made up of smaller software objects?   Click here for a        

What are the instance variables of class Car?   Click here for a    

What method is defined in class Car?   Click here for a