CS 4448 - Fall 1998
Object-Oriented Programming and Design
Homework #4
Due on Monday, September 28.
Bring 2 copies of your homework to class and don't turn them in until
after I give you further instructions. If you can not make class talk
to me before hand and we can work something out.
Do Design for Homework #3
Show your designs using Class Diagrams and Module Diagrams. Be open
minded in your design. Consider future enhancements and see the big
picture. Anticipate future needs that one might have on your design.
It should be noted that no design is ever final, we always go back at
some later date and make modifications. MS Word seemed complete but
then we decide it needs to generate HTML. So if the designers did a
good job it only takes a minor redesign to generate HTML. But then it
is decided that MS Word needs to be not only a word processor but also
a web browser. This time it is a larger redesign but again it is done
with hopes of anticipating future design needs. Enough said, go to
it.
Why fixed names?
The class names and method names are fixed since someone else wants
your classes for use by their classes. This hypothetical, "They",
have created their own stubs for some of the code and will be
replacing them with your code.
This time the syntax I am using is SmallTalk
Classes and class methods that need to work for instantiation
- Dog weight: name: kind:
- Cat weight: name: kind:
- Sprinter weight: name:
- Molecule name: 'Water' (Comment - The string Water is just one example)
- Beaker name: 'MagnesiumChloride' (Comment - Just an example name)
- Magnesium new
- Chlorine new
- Hydrogen new
- Krypton new
- Pine weight: height:
- Plant new
- Animal new
- BeakerHolder new
- CouchPotato weight: name: (Comment - For those from different
cultures, this is a person who watches TV all day and does not move
unless they need a beer or to go to the bathroom)
- Student weight: name:
Some additional classes that might help you design include: Mammal,
Quadraped, Biped, Human, Tree, and last but not least a MaterialObject.
Note: name may not be set after instantiation. Every object for our
design, comes into existence with a name and never changes
it. Periodic
Table for your perusal.
Instances and minimum instance methods
- aDog speak; name; topSpeed; hasLiveYoung; spontaneousMovement
- aCat speak;legs
- aSprinter topSpeed;
- aStudent speak; legs
- aBeaker numberOfAtoms; name
- aMolecule mass; name; chemicalSymbol
- aHydrogen mass; chemicalSymbol
- aKrypton name; family
- aPine deciduous;height
- aPlant alive
- aBeakerHolder find: ; hold: ; giveBack: (Comment: think of
giveBack as unhold, add and remove might give you ideas of what hold:
and giveback: do)
- anAnimal hasSex (Comment: this method is not a social commentary
but a question about gender :)
- aBeaker add: ; remove: (Comment: these methods let you add and
remove atoms to the beaker)
- aCouchPotato speak; topSpeed; spontaneousMovement (Comment: See
Animal vs. Plant in the dictionary. I agree see your question and I
don't know the answer either. Is a CouchPotato Animal or Vegetable or
Mineral, but certainly not the Model of a Modern Major General)
Adam Jonathan Griff,
computer@griffmonster.com
Copyright © University of Colorado. All rights reserved.
Revised: September 23, 1998