Lab 10 :: Mini Project

In this lab, you are not asked to solve one fixed problem. Instead You have to choose and solve a problem of your choice. The idea is to pick some real world activity of your interest and code it in java. Here are the details.

In object oriented programming/design everything of interest is abstracted as an object. We have seen two powerful and structured ways to create new/more-complex objects from the given ones. The first is designing a new class which may have object references of other classes. This captures "contained in/comprises of" relationship. This is also called composition. The second way is to extend an object via inheritance. It captures "is a" relationship (example: car "is a" vehicle) between objects.

The relationship among many real world entities can be captured using the two notions mentioned above. Here are several examples of inheritance (the first two you may already have seen in tutorial).

   
    1. Sports
        Outdoorsports  extends  Sports
        Indoorsports  extends   Sports

        Watersports  extends Outdoorsports
        Airsports  extends Outdoorsports
        Surfacesports  extends Outdoorsports
 
        Waterpolo  extends Watersports
 
        Tabletennis extends Indoorsports
         etc. 
     2. EnggCollege
        IIT extends EnggCollege
        IITK extends IIT
        IITB extends IIT
 
        REC  extends EnggCollege
         etc. 
     3. Two dimensional Geometric figures
          rectangle extends figure 
          square extends rectangle

          Ellipse extends figure 
          circle extends figure

          polygon extends figure
          convex_polygon extends polygon   
             etc.       
             
     4.  KitchenUtensil
         CookingUtensils extends KitchenUtensil
         ServingUtensils extends KitchenUtensil

         PressureCooker extends CookingUtensils
         DinnerPlate extends ServingUtensils
          etc. 

Classification is a very common technique in science also (where we group similar things under one name) trees, fruits, flowers, animals have all been classified in various ways. Of course the works of art, paintings, music, dance, drama have also classifications.

In this lab, you are asked to model a real life entity or phenomenon, of your liking using object orientation mechanism of java. The level of details at which you model the phenomenon is upto you. You may keep in mind the following.

It is preferred that you have inheritance hierarchy more than two levels deep.

Interesting examples usually have both composition and inheritance. For example Painting object may be defined using inheritance, then define Exhibition object as a collection of paintings using composition. Similarly a Dance may be a superclass reference (with subclasses representing specific forms of Dance), and DanceProgramme class may have a sequence of Dance references.

When designing a class, focus on what member variables will capture what you wish to model. How you wish to modify these will give you an idea of what methods you would like to keep. You may have some methods which just represent real life action notionally, like play method in the instrument class or perform method in the dance class or draw method in a figure class.

While defining a subclass, think about which methods should be redefined and what new methods must be added to the subclass. For example, suppose you are doing EnggColleges example, entrance exam info. may be kept in the superclass if it is common to all subclasses (say joint entrance exam etc.)

You are not expected to do a lot of coding, about 80-100 lines of code is ok for this lab. So do not model some complex activity in all its detail, pick a small number of aspects and program them.

Design will be easy for you if you choose to model something of your interest. It may be related to your hobby or academic interest.