Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code the program below. All programs must contain and use a main function Create a program that contains the three classes as follows along with

Code the program below. All programs must contain and use a main function Create a program that contains the three classes as follows along with their respective data:

image text in transcribed

House and Apartment should inherit from the Dwelling class and implement their own __init__ method thatcalls said class on creation. Each printData() method should be overridden to include the class respective variables (ie, the House class should also print out the address and numOfFloors) Each __str__() method should be overridden to return (not print) the data as a formatted string when the object is called as a string get_dwellingType() should return the type of dwelling (house/apartment) Create two objects, one of type House and one of type Apartment. Call all of their functions

and the output should be like this

Output Result: House use print(house.get_dwellingType()) Dwelling Type:House use house.printData() Value:800 Rooms:100 Address:1911 Simcoe St NumberOfFloors:4

Dwelling Type: House use print(house) Value:800 Rooms:100 Address:1911 Simcoe St NumberOfFloors:4

Apartment use print(apartment.get_dwellingType()) Dwelling Type:Apartment use apartment.printData() Value:500 Rooms:1 Address:100 York St ApartmentNumber:3087 Dwelling Type: Apartment use print(apartment) Value:500 Rooms:1 Address:100 York St ApartmentNumber:3087

Dwelling Variables typeOfDwelling value rooms Functions printData() get_dwellingType() _str_0 House Variables address numOfFloors Functions printData() str_0 Apartment Variables address apartment Number Functions printData() _str_0

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

5. Arranging for the training facility and room.

Answered: 1 week ago

Question

1. Discuss the five types of learner outcomes.

Answered: 1 week ago