Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ program 1.0 Class definition (header files contents) -- 16 pts o Class implementation (.cpp files for class implementation) -- 54 pts o main program

c++ program

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1.0 Class definition (header files contents) -- 16 pts o Class implementation (.cpp files for class implementation) -- 54 pts o main program (.cpp for the main program file including non-member functions) 30 pts 7. Any inheritance you will do, please do it public. Define class Leases that has the following: private members: 1. int lease_months: points to an array of integers. Each element in the array represents the amount of money paid as a lease per month. The default value of any element in the array is 100. 2. int leases_size: it is the size of the lease_months array, it represents the number of months in which the apartment was leased. Its default value is 4. private members: 1. int* lease_months: points to an array of integers. Each element in the array represents the amount of money paid as a lease per month. The default value of any element in the array is 100. 2. int leases_size: it is the size of the lease_months array, it represents the number of months in which the apartment was leased. Its default value is 4. public functions: 1. One Constructor (parameterized and default) that takes a value to set all the elements of the array, and the size of the array. If any of these parameters is not passed, then its value is set to the default value. 2. Getter for the leases_size, don't write a setter for it. 3. Getter for the lease_months array at a given month, it receives an index and returns the stored value in that index in the lease_months array. Assume the index is in the proper range. 4. void set_leases(int value, int index): it sets the received value in the received index in the lease_months array. Assume the index is in the proper range. 5. int set_leases(int arr[], int Leases_size); it copies the values in arr to the lease_months array and then returns 1, only if the passed array size equals the lease_months array size. Otherwise, it returns -222. Define class Apartgent which has the following: private data members: 1. double tax: represents the tax of the Apartment. Its default value is 150. protected data members: 1. Leases item_leases: an object of class Leases that represents the Leases of an apartment. public data members: 1. const double area: it represents the area of the apartment. Its default value is 150. Public functions: Public functions: 1. One constructor (parameterized and default): it takes a value to set all the elements of the lease_months array, its size, tax, and rea. If any of these parameters is not passed, then its value is set to the default value. 2. Getter and setter for the tax. 3. Getter for the item_Leases object. 4. void show_report(): it prints the apartment tax, area, and the number of months on which it was leased. Define class Duplex Apartment which is an Apartment that has following attributes: private data members: 1. int floors number: it represents the number of floors in the Duplex apartment. Its default value is 1. 2. static int instances: initialized to 0. It counts the number of Duplex_apartment objects created so far. public functions: 1. One constructor (parameterized and default): it takes a value to set all the elements of the lease_months array, its size, tax, area, and the floors number. If any of these parameters is not passed, then its value is set to the default value. 2. Getter for the Floors_number data member. 3. Getter for the instances data member, make it a static function. 4. multiply_tax(double factor); it updates the tax to be the multiplication of the tax by the factor. 5. Override the show_report function to call the show_report function of the item class and print the floor_number of the Duplex Apartment. 6. A friend function tripleMaxLeases(Duplex_Item & item): it triples (multiplies by 3) the maximum Leases value in the lease_months array. Example: if the maximum value in the lease_months array is 10, then it becomes 30. In the driver program define the following: 1. non-member function of the following form to do the following: void operations(Duplex Apartment cl], int floors, int i, int Leases_value) If the value in the lease_months array in the index (i) is smaller than the Leases_value, then replace the value in the lease_months array at that index with the Leases_value. Do that for all objects in the c array. The following example shows the lease_months arrays of each Duplex Apartment object in c array. celements lease_months O]... (3,4,4,5) (1) .....> (4,3,3,7) [7,3,8,3) If the index (i) is 2 and the Leases_value is 6. Then the lease_months arrays of each Duplex Apartment object incarray should be as follows: celements lease_months CO) -----> (3,4,6,5) (1) .....> 14,3,6,7) (2) -----> 17,3, 8,3) (2) -- a. Define an array of 5 Duplex Apartment objects. b. Ask the user to enter Leases for 4 days. Then, set these Leases in the lease_months array for the last object in the Duplex Apartment array. c. Double the tax of the third object in the Duplex Apartment array. d. Call tripleMaxLeases function for the last object in the Duplex Apartment array. e. Use the operations function to set the second element of the lease_months array to 10, if its value is less than 10. Do that for all objects in Duplex Apartment. f. Print the number of Duplex Apartment objects created so far. & Print the information of all objects of the Duplex Apartment array using show_report function

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions