Answer these question using the given information consider t

Answer these question using the given information

consider the following declarations:
class houseType
{
public:
   void set(string, int, int, int, int, int, double, double);
   void print() const;
   void setStyle(string);
   string getSyle() const;
   void setNumOfBedrooms(int);
   int getNumOfBedrooms() const;
   void setNumOfBedrooms(int);
   int getNumOfBathrooms() const;
   void setNumOfCarsGarage(int);
   int getNumOfCarsGarage() const;
   void setYearBuilt(int);
   int getYearBuilt() const;
   void setFinishedSquareFootage(int);
   int getFinishedSquareFootage() const;
   void setPrice(double);
   double getPrice() const;
   void setTax(double);
   double getTax() const;

   houseType(string = \"\", int = 0, int = 0, int = 0, int = 0, int = 0, double = 0, double = 0);

private:

   string style;
   int numOfBedrooms;
   int numOfBathrooms;
   int numOfCarsGarages;
   int yearBuilt;
   int finishedSquareFootage;
   double price;
   double tax;
};

houseType newHouse; //variable declaration

Assume the definition of class houseType as given above.
Answer the following questions?
a. Write the definition of the member function set so that private members are set according to the parameters.
b. Write the defnition of the member function print that prints the values of the data members.
c. Write the definition of the constructor of the class houseType so that the private member variables are initialized according to the parameters.
d. Write a C++ statement that print the vlue of the object newHouse.
e. Write a C++ statement that declares an object house of type newHouse, and initializes the member variables of house to \"Ranch\", 3,2,2, 2005, 1300, 185000, and 3600.0, respectvely.
f. Which function members are accessors and which are mutators?

Solution

Please find the answers below:

a)

void set(string s, int nBed, int nBath, int nCG, int yB, int fSF, double p, double t) {

style = s;
numOfBedrooms = nBed;
numOfBathrooms = nBath;
numOfCarsGarages = nCG;
yearBuilt = yB;
finishedSquareFootage = fSF;
price = p;
tax = t;

}

b)

void print() const{

cout << \"style = \" << style << \"\ \" <<
\"numOfBedrooms = \" << numOfBedrooms << \"\ \" <<
\"numOfBathrooms = \" << numOfBathrooms << \"\ \" <<
\"numOfCarsGarages = \" << numOfCarsGarages << \"\ \" <<
\"yearBuilt = \" << yearBuilt << \"\ \" <<
\"finishedSquareFootage = \" << finishedSquareFootage << \"\ \" <<
\"price = \" << price << \"\ \" <<
\"tax = \" << tax << \"\ \" << endl;

}

c)

houseType(string s = \"\", int nBed = 0, int nBath = 0, int nCG = 0, int yB = 0, int fSF = 0, double p = 0, double t = 0) {

style = s;
numOfBedrooms = nBed;
numOfBathrooms = nBath;
numOfCarsGarages = nCG;
yearBuilt = yB;
finishedSquareFootage = fSF;
price = p;
tax = t;

}

d)

newHouse.print(); //the print method of houseType class will print all its member variables and its values

e)

houseType newHouse(\"Ranch\", 3, 2, 2, 2005, 1300, 185000, 3600.0) //declare and initializes houseType class

f)

The accessors are the methods which used to get the value of a class\'s member variables, here the accessors in the houseType class are :

string getSyle() const;
   int getNumOfBedrooms() const;
   int getNumOfBathrooms() const;
   int getNumOfCarsGarage() const;
   int getYearBuilt() const;
   int getFinishedSquareFootage() const;
   double getPrice() const;
   double getTax() const;

The mutators are the methods which used to set a value of a class\'s member variables, here the mutators in the houseType class are :

void setStyle(string);
void setNumOfBedrooms(int);
void setNumOfBedrooms(int);
void setNumOfCarsGarage(int);
void setYearBuilt(int);
void setFinishedSquareFootage(int);
void setPrice(double);
void setTax(double);

Answer these question using the given information consider the following declarations: class houseType { public: void set(string, int, int, int, int, int, doubl
Answer these question using the given information consider the following declarations: class houseType { public: void set(string, int, int, int, int, int, doubl
Answer these question using the given information consider the following declarations: class houseType { public: void set(string, int, int, int, int, int, doubl

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site