Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Tutorial 12: Polymorphism // Write your name and your partner's name. // Only one submission is required per pair // Submit only the source

image text in transcribed

// Tutorial 12: Polymorphism

// Write your name and your partner's name. // Only one submission is required per pair // Submit only the source code file (week12.cpp)

//! Pair Programming - Members Names //! Name 1: //! Name 2:

#include #include #include using namespace std;

// The Location class holds general data about the location class Location { public: };

// The House class holds general data about the location class House { private: protected: public: // Default constructor House() {

} // Constructor // Accessors

};

// The Bungalow class represents a bungalow class Bungalow : { private: public: // Default constructor // Constructor #2 // Accessor for deriveType attribute

//Display the houses for rent

};

// The Apartment class represents an apartment class Apartment { private: public: // Default constructor // Constructor #2 // Accessor for deriveType attribute //Display the houses for rent

};

int main() {

system ("pause"); return 0; }

Question: Suppose you are hired to develop a program for a rental house agent. The system is used to advertise all houses for rent. The rental houses include two types of houses: bungalow and apartment houses. Location House -street: string -no Room : int; -town: string #rentRate: double +Location (string"string") +House) + getStreet(): string + House(Location, int, double) + getTown(): string + getLocation():string +getFullLocation(): string + getRoom():int + getRate(): double + getDeposit(): virtual double + display(): virtual void Bungalow -land: int +Bungalow + Bungalow(Location, int, double, int) +getLand():int + getDeposit): double + display:void Apartment -level:int +Apartment() +Apartment Location int, double, int) +getFLevel():int + getDeposit(): double + display:void Figure 1. UML Class Diagram 1. Given the class diagram in Figure 1, write CH program based on the diagram. Note that, the purpose of each operation is as its name implies. Define class Location, class House, class Bungalow and class Apartment with attributes and methods as shown in the class diagram. Class House has pure virtual function, namely getDeposit() and displayO. The deposit for Bungalow is 6 months rent amount while the deposit for Apartment is 3 months rent amount. The information for Apartment and Bungalow to be displayed in display() function are as shown in Figure 2. Question: Suppose you are hired to develop a program for a rental house agent. The system is used to advertise all houses for rent. The rental houses include two types of houses: bungalow and apartment houses. Location House -street: string -no Room : int; -town: string #rentRate: double +Location (string"string") +House) + getStreet(): string + House(Location, int, double) + getTown(): string + getLocation():string +getFullLocation(): string + getRoom():int + getRate(): double + getDeposit(): virtual double + display(): virtual void Bungalow -land: int +Bungalow + Bungalow(Location, int, double, int) +getLand():int + getDeposit): double + display:void Apartment -level:int +Apartment() +Apartment Location int, double, int) +getFLevel():int + getDeposit(): double + display:void Figure 1. UML Class Diagram 1. Given the class diagram in Figure 1, write CH program based on the diagram. Note that, the purpose of each operation is as its name implies. Define class Location, class House, class Bungalow and class Apartment with attributes and methods as shown in the class diagram. Class House has pure virtual function, namely getDeposit() and displayO. The deposit for Bungalow is 6 months rent amount while the deposit for Apartment is 3 months rent amount. The information for Apartment and Bungalow to be displayed in display() function are as shown in Figure 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago