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

Instances and minimum instance methods

I will not list which methods should answer with not understood. I leave this for you to figure out.

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.
  1. aDog _ Dog weight: 40 name: 'Sasha' kind: 'Shepard'.
  2. aCat _ Cat weight: 20 name: 'Romeo' kind: 'Mix'.
  3. aSprinter _ Sprinter weight: 180 name: 'Carl Lewis'.
  4. aMolecule _ Molecule water.
  5. aHydrogen _ Hyrdrogen new.
  6. aKrypton _ Krypton new.
  7. aPine _ Pine weight: 25 height: 20.
  8. aPlant _ Plant new.
  9. anAnimal _ Animal new.
  10. aCouchPotato _ CouchPotato weight: 350 name: 'Bubba'.
  11. aDog speak.
  12. aDog name.
  13. aDog hasLiveYoung.
  14. aDog deciduous.
  15. aCat speak.
  16. aCat legs.
  17. aCat isKindOf: (aDog class name).
  18. aSprinter topSpeed.
  19. aSprinter legs.
  20. aSprinter spontaneousMovement.
  21. aMolecule mass.
  22. aMolecule chemicalSymbol.
  23. aHydrogen mass.
  24. aHydrogen family.
  25. aHydrogen alive.
  26. aKrypton name.
  27. aKrypton family.
  28. aPine deciduous.
  29. aPine speak.
  30. aPine height.
  31. aPlant alive.
  32. aPlant chemicalSymbol.
  33. anAnimal hasSex.
  34. anAnimal speak.
  35. aCouchPotato speak.
  36. aCouchPotato spontaneousMovement. "thought you would like that one"
  37. aCouchPotato isKindOf: Animal.
  38. (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.
  1. Describe how your implementation does and does not conform to the OO paradigm.
  2. How is your SmallTalk version different from your C++ version?
  3. How did creating a detailed Booch-93/UML class diagram effect your final implementation?
  4. 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