In Class - class
Create a class Rectangle.
- The class has attributes length and width, each of which defaults to 1.
- It has member functions to calculate
the perimeter and the area of the rectangle.
- It has set and get functions for
the attributes.
- Set should verify the attribute is a floating point number
larger than 0.0 and less than 20.0.
- What is the class called.?
- What data members are in the class?
- What access modifier should the data member have?
- What member functions need to be defined?
- What does the prototype look like for the area member function?
- What does a get for length prototype look like?
- What does a set for length prototype look like?
- Write the function for area.
- How would the area function be invoked?
- Write the member function for setLength to enforce the data constraints.
- Do we need multiple (overloaded) functions for the contructor?
It
should be able to handle the following instances.
Rectangle a;
Rectangle b(20.0); // Set the length
Rectangle c(10.0,10.0) // set the length and width
- Write the constructor
- What does the header file look like for this project??
- Write the member functions
- Write the main file.
- Compile the project and run it!