Can someone point me in the right direction?

This is a discussion on Can someone point me in the right direction? within the C++ Programming forums, part of the General Programming Boards category; I am in my second level of C++ programming. This is the final assignment, and the first time the teacher ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Can someone point me in the right direction?

    I am in my second level of C++ programming. This is the final assignment, and the first time the teacher has made us write a driver.

    I have it written(I think). I'd like if someone could take a look. I'll post the program instructions so you know what I am trying to do, as well as the code I have written.

    **Yes, I read the homework policy and faq. I don't want anyone to do it for me, just some help, that's all.

    Instructions: 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:

    Code:
    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
    Code:
    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)
    Code:
    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
    driver I wrote:

    Code:
    #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, listing briefs
    	
    	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. 
                                  
                            
                          
                     break;
                     case 2: cout<< "Please input the property number you would like to list.\n";
                             cin>> PropertyNumber;
                     break;
                     case 3:cout<< "Please input the property number of the listiing you would like to delete.\n"
                            cin>> PropertyNumber;
                     break;
                     case 4:cout<< "What listing briefs would you like to save?\n"
                            cin>> listing briefs;
                     break;
                     default:
                     break;
                     
                     
    	}
    	
    	while(cont == 'y' || cont == 'Y');
    	
    	
    	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;
    }
    Property class provided, not to be changed:

    Code:
    #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

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So what is it you actually need help with? You haven't asked any question here.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    2
    Oh yes, sorry! Firstly, the Commercial and Residential classes. More...where do I start? I admit writing classes gives me a bit of trouble(more than a bit). I *think* both should be protected? Beyond that, no real clue...

    Let's start there. A beginning skeleton and usually I can fill it in.

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Shannon1981 View Post
    Let's start there. A beginning skeleton and usually I can fill it in.
    Ok, so write one. They've already told you what you need to put in it.

    Start by writing a class that has all of the members they want it to have. Then think about each one, and who needs to be able to access that particular member. Even better, think about what they've given you, and then write it!

    Believe it or not, there is actually a decent amount of thinking that goes into writing a program.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Point in the right direction
    By peanutym in forum C++ Programming
    Replies: 3
    Last Post: 07-07-2008, 08:49 PM
  2. Point me in the right direction
    By vampje in forum C++ Programming
    Replies: 0
    Last Post: 06-07-2006, 03:52 AM
  3. Can someone point me in the right direction?
    By MadMac in forum C++ Programming
    Replies: 7
    Last Post: 09-19-2005, 03:37 PM
  4. need a point in the right direction
    By sweetly in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2003, 05:19 PM
  5. can someone point me in the right direction?
    By bean583 in forum C Programming
    Replies: 2
    Last Post: 03-19-2002, 09:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21