[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng Dept] / [R J Botting] / [CSci202] / project3
[Text Version] [Syllabus] [Schedule] [Glossary] [Resources] [Grading] [Contact] [Question] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Wed Apr 29 11:11:11 PDT 2009

Contents


    Project 3 Chapter 13 Inheritance and Polymorphism

      Inheritance Please

      To get full credit you need to have at least one class derived from another one, and the derivation needs to make sense. For example,
       	class Knife : public Weapon ....
      is OK because
    1. a Knife is a special kind of Weapon.

      But

       	class Handle : public Knife ...
      is not OK becuase a Handle is a part of a knife.

      UML Please

      Please include a rough diagramn of any classes you code and how they are related. Kno need for attributes and operations unless you are proud of something you have done.

      Remember that when you are stuck writing or debugging code, it helps to shift to pictures and diagrams. Rough UML can help.

      Write a Main Program to test classes

      When asked to develop one or more classes you should also develop and hand in a main program that tests the classes.

      Polymorphism Please

      To test for polymorphism you need to declare a pointer to a base class that actually refers to an object in a derived class:
       		Base * p = new Derived(....);
      and then test for the behavior defined in the derived class:
       		assert ( p->function(...) == the result in derived class );
      for example.

      Common Errors in Inheritance

      1. Forgetting the 'public' in "class Derived : public Basis {....".
      2. Using inheritance where one classes objects are not a special kind of objects of the other class.
      3. Making attributes public rather than writing functions to access them.
      4. Overdoing "protected".

      Reusing code

      If you start by reusing your old code, or from my code, or code from the book, or code from another web site, ... you must add comments in the code acknowledging the source. Otherwise you'll get zero.

      Note -- Many of these projects start with an exercise from chapter 12.

      If you pick one -- start by doing the chapter 12 version and then extend it.

      Suitable Exercises at end of Chapter 13

        13.12 Payroll system

        13.13 Shape hierarchy

        More than in Lab05!

        13.14 Polymorphic Screen Manager for Shapes

        You could start with Lab05 or the hierarchy in the book.

        Big problem -- how to draw shapes on the screen with out a cool graphics package.

        13.15 Package Inheritance

        13.16 Polymophic Banking

      . . . . . . . . . ( end of section Suitable Exercises at end of Chapter 13) <<Contents | End>>

    . . . . . . . . . ( end of section Project 3 Chapter 13 Inheritance and Polymorphism) <<Contents | End>>

    Abbreviations

  1. Algorithm::=A precise description of a series of steps to attain a goal, [ Algorithm ] (Wikipedia).
  2. class::="A description of a set of similar objects that have similar data plus the functions needed to manipulate the data".
  3. Data_Structure::=A small data base.
  4. Function::programming=A selfcontained and named piece of program that knows how to do something.
  5. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular and free C++ compiler.
  6. KDE::="Kommon Desktop Environment".
  7. object::="A little bit of knowledge -- some data and some know how", and instance of a class".
  8. OOP::="Object-Oriented Programming", Current paradigm for programming.
  9. Semantics::=Rules determining the meaning of correct statements in a language.
  10. SP::="Structured Programming", a previous paradigm for programming.
  11. STL::="The standard C++ library of classes and functions" -- also called the "Standard Template Library" because many of the classes and functions will work with any kind of data.
  12. Syntax::=The rules determining the correctness and structure of statements in a language, grammar.
  13. Q::software="A program I wrote to make software easier to develop",
  14. TBA::="To Be Announced", something I should do.
  15. TBD::="To Be Done", something you have to do.
  16. UML::="Unified Modeling Language".
  17. void::C++Keyword="Indicates a function that has no return".

End