Activities

If a fertile imagination has birthed in you a desire to learn more, you can spawn more knowledge of inheritance with the following activities:

  • Create a Point4D class that adds a t coordinate to the (x,y,z) coordinate system created by the Point3D class. The t coordinate stands for time, so you will need to ensure that it is never set to a negative value.
  • Use the members of a football team's offense—lineman, wide receiver, tight end, running back, and quarterback, and design a hierarchy of classes that represent the skills of these players, putting common skills higher up in the hierarchy. For example, blocking is behavior that should probably be in herited by the linemen and tight end classes, and speed is something that should be inherited by wide receivers and running backs.

To see Java programs that implement these activities, visit the tutorial's website at http://www.java24hours.com.

      
Comments