CS 4448 - Spring 1998
Object-Oriented Programming and Design
Homework #3

Due on Tuesday, February 3 at the start of class.

Print out this C++ assignment with a sample run of the assignment. Also tar up the necessary files (.h .cc makefile etc.) for me to test your program and email them to me.

C++ program - And you are?

For this assignment you need to create the classes below and they must respond to the methods in the way specified. Your implementation may respond to additional methods but the methods and and responses should be appropriate for that class. First the instantiation method is given and then examples of method responses follow.

Create the classes below and the constructor

  1. Dog - sasha = Dog(40,"Sasha","Shepard");
  2. Cat - romeo = Cat(20,"Romeo","Mix");
  3. Sprinter - carl = Sprinter(180,"Carl Lewis")
  4. Molecule - water = Molecule("Water")
  5. Hydrogen - h = Hyrdrogen()
  6. Krypton - kr = Krypton()
  7. Pine - pine = Pine(25,20)

Methods to implement and the result

  1. sasha.name() -> "Sasha"
  2. romeo.name() -> "Romeo"
  3. romeo.mass() -> 20
  4. romeo.mass(25) -> 25
  5. romeo.mass() -> 25
  6. sasha.speak() -> "Whof, Whoph"
  7. romeo.speak() -> "Meow"
  8. sasha.legs() -> 4
  9. sasha.hasLiveYoung() -> True
  10. carl.legs() -> 2
  11. carl.speak() -> "Sorry, gotta run"
  12. carl.mass() -> 180
  13. pine.name() -> "Pine"
  14. pine.height() -> 20
  15. pine.deciduous() -> False
  16. water.mass() -> 18.01528
  17. water.symbol() -> "H2O"
  18. water.name() -> "Water"
  19. h.name() -> "Hyrdrogen"
  20. h.mass() -> 1.00794
  21. kr.mass() -> 83.8
  22. kr.family() -> "Noble Gas"
  23. kr.symbol() -> "Kr"

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 would you modify your design to better conform to the OO paradigm?

Adam Jonathan Griff, computer@griffmonster.com
Copyright © University of Colorado. All rights reserved.
Revised: February 1, 1998