-
Classes
Hi, I am new to programming and I need anyone's help on this.
"Creat a class Rectangle. The class attributes length and width, each of which default to 1. It has member functions that calculate the perimeter and the area of the rectangle. It has set and get functions for both length and width. The set functions should verify that length and width are each floating point numbers larger than 0.0 and less than 72.12.
Here's what I have so far, and can't go beyond this:
#include <iostream.h>
class Rectangle // Class Rectangle
{
public:
Rectangle(float=1, float=1); // Constructor
double perimeter(float, float); // Perimeter function
double area(float, float); // Area funcion
void set(float, float);
void get(float, float);
private:
float length;
float width;
}; // End of class Rectangle
Rectangle::Rectangle(float L, float W) // Scope function
{
}
double Rectangle::perimeter(float L, float W, float H)
{
}
double Rectangle::area(float L, float W, float H)
{
}
void Rectangle::set(float L, float W)
{
length =
}
void Rectangle::get(float L, float W)
{
}
int main() // main()
{
return 0;
} // End of main()
Thanks
-
Okay, so what do you need help with? Would you like someone to write all the code for you?
-
Do you know how to work with classes?
if yes... Then you should be able to write that class because it's a very simple, and straight forward example.
if not... I suggest you read some tutorials about classes or read your book if you have one, then post any questions you have here.
-
1: You have your perimiter and area functions taking 3 arguments when their class declarations says they take 2.
2: All you have to do now is put in the formula to calculate the area and perimiter, and make sure in the Set... functions that the number bieng set is greater than 0.0 and less than 72. whatever.