class get and set

im having trouble with double land::getwidth() { width=wid}
the full description of this question is
Skill set: Creating a simple class
Step 1: Follow along with lecture in class to code the Rectangle Class
Attributes:
length
width
Behaviors
setLength validate data; return false if invalid
setWidth validate data, return false if invalid
getLength
getWidth
getArea
getPerim
Test that all the functions of this class work.
Step 2: Now use this class in an application.
A home improvement store wants an application to calculate the cost of flooring for a room or
fencing of a rectangular area of land. The user inputs the dimensions of the room or land and the
price of the product. Calculate and display the area or perimeter to cover and the total cost. You
will use the Rectangle class to represent the measurements of the room or the land. The
calculation of the flooring or fencing cost is done in main, NOT in the class. Create additional
variables in main as needed. DO NOT ADD ANY ADDITIONAL ATTRIBUTES TO THE
CLASS!



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  #include<iostream>

using namespace std;
class land 
{ 
    private:
    double width; 
    double length; 
  
	public:
    void setLength(double);
    double getwidth();

}; 
void land::setLength(double len)
{
	length=len;
	//cout "length is"<<len<<endl;
}
double land::getwidth()
{
	width=wid;	
}
int main()
{
	string choice;
cout << "1- Price of flooring "<<endl;
cout<<"2- Price of fencing "<<endl;
cout<<"3- quit"<<endl;
cin >> choice;

if(choice=="1" )
{
   cout<<"Enter length, in feet:";
   cin>>len;
  
  cout<<"Enter the width, in feet:";
  cin>>wid; 
  
    
}
else if( choice=="2" ){
    // do menu option a
}
else (choice == "3"); 
{
   cout<<"Alrighty you quit"<<endl;
}

}
re.
1
2
3
4
double land::getwidth()
{
	return width;
}
Topic archived. No new replies allowed.