|
CSIS 250 Spring 2000 Assignment #3 Date Assigned: February 9, 2000 Date Due: February 18, 2000
1. Create a class CRectangle. 2. The class has attributes length and width of integer type, each of which defaults to 1. 3. It has member functions that calculate the perimeter and the area of the rectangle. 4. It has set and get functions for both length and width. The set function should verify that length and width are each integer values larger than 0 and less than 20. 5. A display function to show the dimensions of a rectangle. 6. Another constructor with given values for length and width. 7. A function to set the length and width of the rectangle. 8. A function to get the length and width of the rectangle. Use the following class declaration and the comments as a guide. Write the necessary test functions (one test function for each function) to make sure that each function works properly. Submit the following items: 1. Printed source code 2. Output from the sample runs 3. Self-evaluation sheet
class CRectangle { private: int length; int width; public: CRectangle(void); //default constructor CRectangle(int len, int wid); //another constructor int perimeter(void); //returns perimeter int area(void); //returns area void setDimension(int len, int wid); //sets length and width void setLength(int len); //sets length void setWidth(int wid); //sets width int getLength(void); //returns length int getWidth(void); //returns width void getDimension(int &len, int &wid); //gets length and width void display(void); //displays length and width };
Self-Evaluation Form
|