Q1) (
8points)
Do exercise 13.13. Just use the shape
hierarchy in fig. 12.3 (you don’t need to extend it or create a new one).
Q2) (7 points) Do exercise 14.6. Use the following class as
the user-defined type:
// A class for 2D points (x,y)class Point {
public:
// Default constructor
Point(double x = 0.0, double y = 0.0) { xval = x; yval = y;}
// getters double x() { return xval; } double y() { return yval; } // Add or subtract two points. Point add(Point b) { return Point(xval + b.xval, yval + b.yval); } Point sub(Point b) { return Point(xval - b.xval, yval - b.yval); } // Move the existing point. void move(double a, double b) { xval += a; yval += b; } // Print the point on the stream. The class ostream is a base class // for output streams of various types. void print(ostream &strm) { strm << "(" << xval << "," << yval << ")"; } private:
double xval, yval; };
(For
your practice only – you don’t have to hand it in). Try exercise
15.14.
Q1) ( 9 points: 5 + 4)
a) Do exercise
12.3.
b) Give two original examples (one for inheritance
and one for aggregation, using UML class diagrams) where
inheritance/aggregation will be more appropriate.
Q2)
(6 points) Do exercise 12.6.
(For your practice only – you
don’t have to hand it in). Try exercise 11.13 on complex numbers.
Required
You are free to use any other UML guides available on the
internet. The Rational Rose UML modeling software is available in the CIS
undergraduate lab for hands on UML design practice. For home use, you can
download the free BOUML toolbox here: http://bouml.free.fr/
§
Course name
§
Assignment number
§
Your name
§
Your email
address
§
Date
Send comments to the CS 304 TA