Assignment 12

# Assignment 12 - Assignment#12 CS 170A Spring 2006 Due...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Assignment #12 CS 170A, Spring 2006 Due Wednesday, April 26 Part 1 (practice exercises) 1. Read chapter 13 in the text. 2. Do review questions 1, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14 on pages 697698. 3. Do programming exercises 1, 2, 4 on pages 698700. Part 2 (to turn in) We wish to define classes for some simple twodimensional geometric objects, both for storing and manipulating the objects, and for drawing the objects to some device (perhaps a graphical window, or simply the standard output). However, we would like to make use of C++ polymorphism to allow all objects to be treated in a similar manner. One possible solution is as follows. As you do each of the following tasks, keep in mind that your code should work with the test driver given on the last page. 1. Define an abstract base class, called Object , for the geometric objects (the actual objects will be derived from this class). The requirements for this class are as follows. The Object class should contain a nested structure for representing points in the plane. The interface for this structure must be: struct Point { float x, y; Point(float X=0,float Y=0); void Set(float X, float Y); static const Point ORIGIN; }; where ORIGIN is to represent the origin (the point whose x and y com- ponents are both 0). The Object class should have at least one data member for the center of the object, this data member must be private to the class. The Object class should have at least one constructor that takes a single parameter, a Point representing the center of the object. 1 There should be a member function for viewing and setting the center of the object, called Center , which takes no parameters and returns objects of type Point (although possibly a reference)....
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

Assignment 12 - Assignment#12 CS 170A Spring 2006 Due...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online