A good answer might be:

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 (a simple program, but good enough for now).

class Car
{
  // data
  int startMiles;   // Stating 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 is the method of class Car?   Click here for a