Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Realty Class: This is the abstract base class. It has following structure: Class variables: price: Price of realty. m2: Total m2 of realty. tax: Annual

image text in transcribedRealty Class: This is the abstract base class. It has following structure: Class variables: price: Price of realty. m2: Total m2 of realty. tax: Annual tax of realty. city: City of Realty Class Functions: Realty(): In this constructor function, you may initialize variables of your object. getPrice(): This function returns the price. setPrice(int _price): Changes the value of price. getTax(): This function returns the tax. setTax(int _tax) Changes the value of tax. virtual void CalculatePrice()=0: This virtual function is only defined as a prototype for sub classes. In sub classes it will calculate the price according to some rules. virtual void CalculateTax()=0: This virtual function is only defined as a prototype for sub classes. In sub classes it will calculate the tax according to some rules. virtual void getInput()=0: This function gets inputs from the user. Its only defined as a prototype in the abstract class. Then, in the sub classes it will be overloaded. virtual void print(): This function prints class variables to give information. You may write a print function in your cpp file too or you may leave it undeclared if you define your function in the format virtual void print()=0. Home Class: This is a child class inherited from abstract Realty Class. It has following structure: Class variables: numberofrooms: number of rooms that home has. balcony: boolean Class Functions: home(): Default constructor of home class. You may initialize class variables in this function. getInputs(): In this function, program gets inputs from the user for the variables of abstract parent class and also home class. CalculateTax(): In this function, program calculates the annual tax for home. While calculating tax, program should consider the m2 and location of home. Possible cities: New York, Los Angeles, Miami, Denver, Utah. Formula: i. New York: 1.75 ii. Los Angeles: 1.70 iii. Miami: 1.60 iv. Denver: 1.2 v. Utah: 1.4 Annual Tax=total m2 of the house x 10 x location value. CalculatePrice(): In this function, program calculates the price of home according to the given formula: Price= Print(): In this function, you will print tax, price, m2, city, number of rooms and balcony information of the home. land Class: This is a child class inherited from abstract Realty Class. It has following structure: Class variables: Improved_area: This is a boolean variable that is true if land is in improved area. Class Functions: land(): This is default constructor of the class. You may initialize class variable improved_area in this function. CalculatePrice(): In this function, program should calculate the price of land according to the given formula: i. New York: 1.75 ii. Los Angeles: 1.70 iii. Miami: 1.60 iv. Denver: 1.2 v. Utah: 1.4 Price= m2 of the land x 500 x location value. CalculateTax(): In this function, program should calculate the tax of land according to the given formula: Tax= m2 of the land * 5 * location value. getInputs(): In this function, program gets inputs from the user for the variables of abstract parent class and also land class. Print(): In this function, you will print tax, price, m2, city and improved area information of the land. shop Class: This is a child class inherited from abstract Realty Class. It has following structure: Class variables: income: This is an int variable that stores the income of shop. Class Functions: shop(): This is default constructor of the class. You may initialize class variable income in this function. CalculatePrice(): In this function, program should calculate the price of shop according to the given formula: Price= income of shop x 100. CalculateTax(): In this function, program should calculate the tax of shop according to the given formula: Tax= income of shop x 1.25. getInputs(): In this function, program gets inputs from the user for the variables of abstract parent class and also shop class. Print(): In this function, you will print tax, price, m2, city and income information of the shop. Main Class and Functions: You should define an array of object from the abstact parent class so that you will apply polymorphism. You may define size of array as 3. There are some functions you need to define in your main class: int totalTax(realty **obj,int n): This function takes object as type of abstract base class realty so that it may work with all kind of classes that are inherited from abstract base class. Then, it will calculate the total tax of objects that exists in the array. int totalPrice(realty **obj,int n): This function takes object as type of abstract base class realty so that it may work with all kind of classes that are inherited from abstract base class. Then, it will calculate the total price of objects that exists in the array.

Realty #price: int #m2:int #tax:int #city: string +Realty(): Constructor getPrice(): int +setPrice(int price): void +getTax(): int +setTax(int_tax) : void CalculatePrice(): virtual void +CalculateTaxi) : virtual void +getinput(): virtual void +print(): virtual void enter monthly income: 9500 enter m2: 450 enter city: LosAngeles ---Land- is land in an improved area? (yes or no) yes enter 12: 550 enter city: Miami enter number of rooms: 5 does home have a balcony? (yes or no) yes enter 12: 200 enter city: Denver ----Shop Info--- m2: 450 city: LosAngeles income : 9500 price: 950000$ tax: 11875$ --Land Info--- home land m2: 550 city: Miami improved_area: 1 price: 440000$ tax: 52805 --Home Info-- -balcony: boolean -numberofrooms:int CalculatePrice() : void CalculateTax(): void +getInput) : void print) : void thome): default const shop -income: int CalculatePrice(): void +Calculate Tax():void +getInput(): void print(): void +shop(): default const getincome(); int +setlncome (income:int) : void improved area: boolean Hand): default const +CalculatePrice() : void +CalculateTax(): void +getInput) : void print) : void m2: 200 city: Denver number of rooms: 5 balcony: 1 price: 3000605 tax: 24005 --TOTALS total price: 16900005 total tax: 195555 Process exited after 47.57 seconds with return value o Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions