Csc.216/s08/nurture strength: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
     (1) Obtain a piece of cardboard (or poster board) of reasonable size, and cut it into the shape of a basic car chassis.
     (1) Obtain a piece of cardboard (or poster board) of reasonable size, and cut it into the shape of a basic car chassis.


     (2) Using markers or crayons, add some basic details to the car shape, and for each detail, write a description on the related of the  
     (2) Using markers or crayons, add some basic details to the car shape, and for each detail, write a description on the related of the car.  For example, if we assume that our car has an engine, we will draw an outline of an engine, on the shape we just drew, we will write "engine."  This is for concreteness' sake, so that participants in the activity will have a visual indicator of each of the features of the basic car.
car.  For example, if we assume that our car has an engine, we will draw an outline of an engine, on the shape we just drew, we will write "engine."  This is for concreteness' sake, so that participants in the activity will have a visual indicator of each of the features of the basic car.


     (3) Add a few more details and descriptions in order to give a basic layout for our simple car.  This car will represent our base class, with each of the labeled features representing individual variables and/or methods.
     (3) Add a few more details and descriptions in order to give a basic layout for our simple car.  This car will represent our base class, with each of the labeled features representing individual variables and/or methods.

Revision as of 03:12, 16 April 2008

Arguably one of the most powerful features of any object-oriented language is that of inheritance. This feature allows the programmer to define a basic object type (the base class), and then extend that object and its functionality in further classes (derived class). The derived classes contain the same variables and functions of the original class, but allow the programmer to extend the original functionality to whatever degree is necessary, without actually changing the functionality of the original base class. Unfortunately, it is often the case that beginning programmers have a difficult time fully grasping the concept of inheritance, despite its applicability and usefulness. This exercise will present a fun and engaging method for representing a more concrete example of the inheritance process, and will hopefully lead to a more comprehensive understanding of the inheritance process.

  • NOTE: The base object used in this example will be a car; however, you can make your base class anything that you want, as long as it is within the scope of the exercise.
   (1) Obtain a piece of cardboard (or poster board) of reasonable size, and cut it into the shape of a basic car chassis.
   (2) Using markers or crayons, add some basic details to the car shape, and for each detail, write a description on the related of the car.  For example, if we assume that our car has an engine, we will draw an outline of an engine, on the shape we just drew, we will write "engine."  This is for concreteness' sake, so that participants in the activity will have a visual indicator of each of the features of the basic car.
   (3) Add a few more details and descriptions in order to give a basic layout for our simple car.  This car will represent our base class, with each of the labeled features representing individual variables and/or methods.