CS 4448 - Spring 1998
Object-Oriented Programming and Design
Homework #4
Due on Tuesday, February 10 at the start of class.
Print out this SmallTalk assignment with a sample run of the
assignment. You must use and print out the workspace example from
below as your test. All your work
should be placed under one category called HW#4 and that .st file, which I
must be able to file back in, emailed to me.
Part 1. Design
Look at the methods and classes below. Generate a design showing the
inheritance hierarchy. The design is to be done as a class diagram in
either Booch-93 or UML. The design needs to show where, as in which
class, the instance variables, methods, and initializations are
defined.
Part 2. SmallTalk program - And you are?
For this assignment you need to create the classes below and they
must respond to the methods in the workspace example. Your
implementation may respond to additional methods but the methods and
and responses should be appropriate for that class. Note: Think about
inheritance in your design and what makes sense. Allowing aHydrogen to
change its name to Krypton is a bad idea. Hint, the hasLiveYoung methods
response is based on biology. It is VERY important that your implementation
match your design!!!
Classes and class methods that need to work for instantiation
- Dog weight: name: kind:
- Cat weight: name: kind:
- Sprinter weight: name:
- Molecule water
- Hyrdrogen new
- Krypton new
- Pine weight: height:
- Plant new
- Animal new
- CouchPotato weight: name:
Instances and minimum instance methods
I will not list which methods should answer with not understood. I
leave this for you to figure out.
- aDog speak; name; topSpeed; hasLiveYoung; spontaneousMovement
- aCat speak;
- aSprinter topSpeed;
- aMolecule mass; name; chemicalSymbol
- aHydrogen mass; chemicalSymbol
- aKrypton name; family
- aPine deciduous;height
- aPlant alive
- anAnimal hasSex "this is a comment, it is not a social commentary
but a question about gender :)"
- aCouchPotato speak; topSpeed "for foreigners, this is someone who
sits infront of the TV allday"
Required Workspace
If it returns an error then where you would see the output put
"error: message not understood" or whatever is the appropriate error
message.
- aDog _ Dog weight: 40 name: 'Sasha' kind: 'Shepard'.
- aCat _ Cat weight: 20 name: 'Romeo' kind: 'Mix'.
- aSprinter _ Sprinter weight: 180 name: 'Carl Lewis'.
- aMolecule _ Molecule water.
- aHydrogen _ Hyrdrogen new.
- aKrypton _ Krypton new.
- aPine _ Pine weight: 25 height: 20.
- aPlant _ Plant new.
- anAnimal _ Animal new.
- aCouchPotato _ CouchPotato weight: 350 name: 'Bubba'.
- aDog speak.
- aDog name.
- aDog hasLiveYoung.
- aDog deciduous.
- aCat speak.
- aCat legs.
- aCat isKindOf: (aDog class name).
- aSprinter topSpeed.
- aSprinter legs.
- aSprinter spontaneousMovement.
- aMolecule mass.
- aMolecule chemicalSymbol.
- aHydrogen mass.
- aHydrogen family.
- aHydrogen alive.
- aKrypton name.
- aKrypton family.
- aPine deciduous.
- aPine speak.
- aPine height.
- aPlant alive.
- aPlant chemicalSymbol.
- anAnimal hasSex.
- anAnimal speak.
- aCouchPotato speak.
- aCouchPotato spontaneousMovement. "thought you would like that one"
- aCouchPotato isKindOf: Animal.
- (aKrypton class name) = (aHydrogen class name).
Extra Workspace
In this space feel free to show off what your objects can do or not
do.
Part 3 Questions
Answer these questions after you have completed the preceding.
- Describe how your implementation does and does not conform to the
OO paradigm.
- How is your SmallTalk version different from your C++ version?
- How did creating a detailed Booch-93/UML class diagram effect
your final implementation?
- Do you believe your code is general and reusable?
Adam Jonathan Griff,
computer@griffmonster.com
Copyright © University of Colorado. All rights reserved.
Revised: February 1, 1998