Project01
Home ] Up ]

 

CSIS 250 Summer 2000 Assignment #1

Date Assigned: July 10, 2000

Date Due: July 13, 2000

Add the following seven member functions and a test function for each member function as discussed in the class to the CRectangle class.

Function name

Brief description

int area(void);

Calculates and returns the area of a rectangle.

void setDimension(int len, int wid);

Sets length and width of a rectangle to the given values of len and wid.  If the value of len or wid is out of range,  then it is set to the default value of 1.

void setLength(int len);

Sets the length of a rectangle to the given value of len.  If the value of len is out of range, then it is set to the default value of 1.

void setWidth(int wid);

Sets the width of a rectangle to the given value of wid.  If the value of wid is out of range, then it is set to the default value of 1.

int getLength(void);

Returns the length of the rectangle.

int getWidth(void);

Returns the width of the rectangle.

void getDimension(int &len, int &wid);

Returns the length and width of the rectangle through the len and wid parameters.

Each function should be properly documented and the output should be properly labeled.  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.       Printed Output from the sample runs

3.       Self-evaluation sheet

 

 

 

class CRectangle

  {

  private:

    int length;

    int width;

  public:

    CRectangle(void);

    CRectangle(int len, int wid);

    int perimeter(void);

    void display(void);

    int area(void);                       //calculate area

    void setDimension(int len, int wid);  //set length and width

    void setLength(int len);              //set length

    void setWidth(int wid);               //set width

    int getLength(void);                  //get length

    int getWidth(void);                   //get width

    void getDimension(int &len, int &wid);//get length and width

  };

 


Self-Evaluation Form

Function member

Maximum Score

Your Score

int area(void)

3

 

void setDimension(int len, int wid);

3

 

void setLength(int len);

3

 

void setWidth(int wid);

3

 

int getLength(void);

3

 

int getWidth(void);

3

 

void getDimension(int &len, int &wid);

3

 

Total points for member functions (one point each), test functions (one point each), and sample runs (one point each)

21