using python: i always rate answer. please answer the 3 questions. Thanks 1)Supp
ID: 3812453 • Letter: U
Question
using python: i always rate answer. please answer the 3 questions. Thanks
1)Suppose a class called Movie is to be written which will allow the user of this class to enter these statements and no errors are generated.
from Movie import *
m1 = Movie(“Gone with the Wind”, 1959)
m2 = Movie( )
Write the constructor method for the Movie class that allows those statements to work.
2)Show the heading line only for a class called empSalaried that inherits data and methods from the Employee class.
3)Suppose a class called House has private data members called numRooms, squareFootage, marketValue.
a.Write the EXACT Python code that would appear in the House class for the following:
b.Constructor: accepts the # of rooms, square footage, and market value.
c.Method that allows retrieval of the number of rooms.
d.Method that allows revision/change of the square footage
e.Method that will allow the users of the House class to print their h1 object using a statement such as print(h1) so that it displays as shown:
Number of Rooms: 5
Square Footage: 2040
Market Value: $215,000
Explanation / Answer
class Movie(object):
def __init__(self,movie_name = None, year =None):
self.movie_name =movie_name
self.year = year
class House(object):
def __init__(self,numRooms, squareFootage, marketValue):
self.numRooms = numRooms
self.squareFootage = squareFootage
self.marketValue = marketValue
def retrievenoofrooms(self):
return self.numRooms
def changesquarefootageval(self, val):
print("SquareFootage val before change",self.squareFootage)
self.squareFootage = val
print("SquareFootage val after change",self.squareFootage)
def printobject(self):
print("Number of Rooms: " '{}'.format(self.numRooms))
print("Square Footage: " '{}'.format(self.squareFootage))
print("Market Value: $" '{}'.format(self.marketValue))
if __name__ == '__main__':
m1 = Movie("Gone with the Wind", 1959)
m2 = Movie()
h1 = House(5,2040,215400)
h1.retrievenoofrooms()
h1.changesquarefootageval(5000)
h1.printobject()
'''I have finished 1 and 3 however i did not get the 2nd question. The Employee class is not mentioned it will be difficult to inherit the Employee class in empSalaried '''
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.