Answer:
class Home(object):
def __int__(self):
room1()
# room1 is the bedroom, you could either sleep or leave the room
def room1(self):
print("Room 1")
choices = ['sleep', 'leave']
for _ in iter(list, 0):
mychoice = input("What do you want to do here sleep/leave: ")
if mychoice == choice[0]:
print("You are sleeping")
elif mychoice == choice[1]:
self. room2()
else:
self. game_over()
# room2 is the living room for fun and recreation
def room2(self):
print("Room 2")
choices = ['watch a movie', 'dance', 'call a friend', 'leave']
mychoice = input("What do you want to do here: ")
for _ in iter(list,0):
if mychoice == choice[0]:
print("I love this movie")
elif mychoice == choice[1]:
print("You are a good dancer.")
elif mychoice == choice[2]:
self. room1()
else:
self. game_over()
# this method ends the program
def game_over(self):
quit()
Explanation:
The simple python object oriented program defines class with three methods room1, room2 and game_over which are all linked from the __init__ method from where the room1 is call first.