Final Program help.

Gonna post the assignment and what I have so far. Please tell me here I am going wrong here. first, here is the instructor's directions:


Program 4: Real Estate Program
You are to create a Real Estate Management Program. The program should allow you to create a list of Commercial or Residential properties, delete properties from the list, print the list to the screen, or save the list to a file. The user should be allowed to run the program until they decide to quit. To implement this program you will need to first implement 3 classes:


Property
member variables:
PropertyNumber – a unique 7 digit number to reference the property
Address – street address
City, State, ZIPCode
Stories - number of stories
Condition - condition of the property (1 - Excellent, 2 - Fair, 3 – Poor)
YearBuilt – the year the property was built
double MarketValue – the current market value of the property ($)
type - 1 for residential, 2 for commercial. No setter needed
member functions:
Constructors – Optional
getters and setters for member variables
print() – this function should be overridden by the child classes but can be implemented to avoid redundancy
double calculatePropertyTaxes() – this function should be overridden by the child classes for now just return 0
double calculateRent() – this function should be overridden by the Commercial class for now just return 0



ResidentialProperty inherits from Property
member variables:
Style - Single-family, Multi-Unit, SemiDetached, Portable-Dwelling, etc
Bedrooms – number of bedrooms
Bathrooms – number of bathrooms (can have half baths)

member function:
Constructors – Optional. I used it to set the type to its proper value
getters and setters for member variables
print() – override this function to print common and specific info
double calculatePropertyTaxes() – override this function (property taxes for residential property is 5% of market value)


CommercialProperty inherits from Property
Member variables
MaxOccupancy - maximum number ppl that can be in the building
BuildingSize - square footage
RentPerSqFt; - Rent per sq ft

Member functions:
Constructors – Optional. I used it to set the type to its proper value
getters and setters for member variables
print() – override this function to print common and specific info
double calculatePropertyTaxes() – override this function (property taxes for residential property is 15% of market value)
double calculateRent() – this function uses the building size and the rent per sq. ft to calculate total rent


Property Class, not to be changed:

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
52
#ifndef PROPERTY_H
#define PROPERTY_H
#include <iostream>
using namespace std;
class Property
{
	//member variables:
	protected:
		int PropertyNumber; //a unique 7 digit number to reference the property  
	    string Address; //street address
	    string City, State, ZIPCode;
		int Stories; //number of stories 
	    int Condition ;// condition of the property (1 - Excellent, 2 - Fair, 3 � Poor)
	    int YearBuilt; //the year the property was built
	    double MarketValue; // the current market value of the property ($)
	    int type; //1 for residential, 2 for commercial. No setter needed
	//member functions:
	public:
		//Constructors � Optional 
		Property(int pN, string add, string cty, string st, string z,
			int str, int c, int y, double mv, int t)
		{
			PropertyNumber = pN;
			Address = add;
			City = cty;
			State = st; 
			ZIPCode = z;
			Stories = str; //number of stories 
			Condition = c;// condition of the property (1 - Excellent, 2 - Fair, 3 � Poor)
			YearBuilt = y; //the year the property was built
			MarketValue = mv; // the current market value of the property ($)
			type = t; //1 for residential, 2 for commercial. No setter needed
		}
	
	
	//getters and setters for member variables
		int getPropertyNumber(){return PropertyNumber;} //a unique 7 digit number to reference the property  
	    string getAddress(){return Address;} //street address
	    string getCity(){return City;}
		string getState(){return State;} 
		string getZIPCode(){return ZIPCode;}
		int getStories(){return Stories;} //number of stories 
	    int getCondition(){return Condition;}// condition of the property (1 - Excellent, 2 - Fair, 3 � Poor)
	    int getYearBuilt(){return YearBuilt;} //the year the property was built
	    double getMarketValue(){return MarketValue;} // the current market value of the property ($)
	    int gettype(){return type;}
	
		virtual void print(){} //� this function should be overridden by the child classes but can be implemented to avoid redundancy
		virtual double calculatePropertyTaxes() {return 0;} // this function should be overridden by the child classes for now just return 
		virtual double calculateRent(){return 0;} // this function should be overridden by the Commercial class for now just return 0
};
#endif 


Driver I wrote:

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <string>
#include <iostream>
#include "property.h"
#include "commercialproperty.h"
#include "residentialproperty.h"
using namespace std;


int main()

{
    int Choice,Select, PropertyNumber, YearBuilt, ZipCode, Bedrooms,Type, Stories, MaxOccupancy, 
    double RentPerSquareFoot, Bathrooms
    string Style, StreetAddress, City, State, 
	
	do
	{
		system("cls");
		Property.showMenu();
		cout <<"- Real Estate Program -\n\n"
		     <<" 1.Enter new listing\n"
		     <<" 2.Print listing\n"
		     <<" 3.Delete listing\n"
		     <<" 4.Save listing briefs to file \n\n"
		     <<"Enter Selection: ";
		     
		     cin>> choice;
		     switch(choice)
		     {
                 case 1: 
                      {
                           cout<< "Select 1 for Residential or 2 for Commercial\n";
                           cin>> select;
                           If (select == 1);
                              cout<< "What is the style?\n?";
                              cin>> style;
                              
                              cout<< "What is the Property Number?\n";
                              cin>> PropertyNumber;
                      
                              
                              cout<< "What is the Street Address?\n";
                              cin.clear();
                              fflush(stdin);
                              getline(cin, StreetAddress);
                              
                              cout<< "What City is it in?\n"
                              cin.clear();
                              fflush(stdin);
                              getline(cin, City);
                              
                              cout<< "What state is it in?\n";
                              cin.clear();
                              fflush(stdin);
                              getline(cin, State);
                              cout<< "What is the zip code of the property\n?";
                              cin>>ZipCode;
                              
                              cout<< "How many Bedrooms does the property have?\n";
                              cin>> Bedrooms;
                              
                              cout<< "How many bathrooms does the property have?\n?";
                              cin>>Bathrooms;
                              
                              cout<< "How many stories is the property?\n?";
                              cin>> Stories;
                              
                              cout<< "What condition is the property in?\n" ;
                              cin>> Condition;
                              
                              cout>> "What year was the property built?\n"
                              cin<< YearBuilt;
                              
                              cout<< "What is the Market Value of the property?\n";
                              cin>> MarketValue;
                              
                             Type=1. 
                              
                        
                      //blah
                 break;
                 case 2://blah
                 break;
                 case 3://blah
                 break;
                 case 4://blah
                 break;
                 default:
                 break;
                 
                 
	}
	
	while(cont == 'y' || cont == 'Y');
	
	view1.setMessages(myBlog.getMessages()); //copying the owner vector into the veiwer vector
	do
	{
		system("cls");
		view1.showMenu();
		cout <<"Enter (C) to continue or (Q) to quit. ";
		cin >> cont;
	}
	while(cont == 'y' || cont == 'Y');
	system("pause");
	return 0;
}



whats the problem?
im stuck blueberry. not quite sure what do to with the residential and commercial classes.
SORRY, forgot about this thread....

you can use 2 vectors of a residential and commercial class.

vector<ResidentialProperty> Rprops;
vector<CommercialProperty> Cprops;

with the vector you can add and remove elements at will.
so, to list a new ResidentialProperty

Rprops.push_back(newResidentialProperty);

soo...

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <string>
#include <iostream>
#include "property.h"
#include "commercialproperty.h"
#include "residentialproperty.h"
using namespace std;


int main()

{
    int Choice,Select, PropertyNumber, YearBuilt, ZipCode, Bedrooms,Type, Stories, MaxOccupancy, 
    double RentPerSquareFoot, Bathrooms, BuildingSize
    string Style, StreetAddress, City, State, 
     vector<ResidentialProperty> Rprops;
      vector<CommercialProperty> Cprops;
	
	do
	{
		system("cls");
		Property.showMenu();
		cout <<"- Real Estate Program -\n\n"
		     <<" 1.Enter new listing\n"
		     <<" 2.Print listing\n"
		     <<" 3.Delete listing\n"
		     <<" 4.Save listing briefs to file \n\n"
		     <<"Enter Selection: ";
		     
		     cin>> choice;
		     switch(choice)
		     {
                 case 1: 
                      {
                           cout<< "Select 1 for Residential or 2 for Commercial\n";
                           cin>> select;

                              
                              cout<< "What is the Property Number?\n";
                              cin>> PropertyNumber;
                      
                              
                              cout<< "What is the Street Address?\n";
                              cin.clear();
                              fflush(stdin);
                              getline(cin, StreetAddress);
                              
                              cout<< "What City is it in?\n"
                              cin.clear();
                              fflush(stdin);
                              getline(cin, City);
                              
                              cout<< "What state is it in?\n";
                              cin.clear();
                              fflush(stdin);
                              getline(cin, State);
                              cout<< "What is the zip code of the property\n?";
                              cin>>ZipCode;

			      cout<< "How many stories is the property?\n?";
                              cin>> Stories;
                              
                              cout<< "What condition is the property in?\n" ;
                              cin>> Condition;
                              
                              cout>> "What year was the property built?\n"
                              cin<< YearBuilt;
                              
                              cout<< "What is the Market Value of the property?\n";
                              cin>> MarketValue;

                              
			      if (select==1){
                              cout<< "How many Bedrooms does the property have?\n";
                              cin>> Bedrooms;
                              
                              cout<< "How many bathrooms does the property have?\n?";
                              cin>>Bathrooms;
			      
			      cout<< "What is the style?\n?";
                              cin>> style;
			      ResidentialProperty N
			      //then you just set the values
			      Rprops.push_back(N);
                              }
			      
			      if (select==2){
			      cout<< "What is the max occupancy?\n?";
			      cin<<MaxOccupancy;
			      cout<< "What is the rent/sqrft?\n?";
			      cin<<RentPerSquareFoot;
			      CommercialProperty N
			      //then you just set the values
			      Cprops.push_back(N);
			      }
                              
                        
                      //blah
                 break;
                 case 2://blah
                 break;
                 case 3://blah
                 break;
                 case 4://blah
                 break;
                 default:
                 break;
                 
                 
	}
	
	while(cont == 'y' || cont == 'Y');
	
	view1.setMessages(myBlog.getMessages()); //copying the owner vector into the veiwer vector
	do
	{
		system("cls");
		view1.showMenu();
		cout <<"Enter (C) to continue or (Q) to quit. ";
		cin >> cont;
	}
	while(cont == 'y' || cont == 'Y');
	system("pause");
	return 0;
}
Last edited on
Topic archived. No new replies allowed.