Question: class Player ( object ) : def _ _ init _ _ ( self , name, place ) : Create a player
class Playerobject: def initself name, place: Create a player object.""" self.name name self.place place self.backpack def lookself: self.place.look #RQ def gotoself direction: Go to direction if it's among the exits of player's current place. swift PlaceSwift Hall', 'You are at Swift Hall', bcc PlaceBearcat Cafe', 'You are at Bearcat Cafe', swift.addexitsbcc bccaddexitsswift me Playerplayer swift megotoBearcat Cafe' You are at Bearcat Cafe meplace.name 'Bearcat Cafe' megotoBearcat Cafe' Can't go to Bearcat Cafe from Bearcat Cafe. Try looking around to see where to go megotoSwift Hall' You are at Swift Hall YOUR CODE HERE #RQ def talktoself person: Talk to person if person is at player's current place. robert CharacterRobert 'Have to run for lecture! sathergate PlaceSather Gate', 'You are at Sather Gate', robert me Playerplayer sathergate metalktorobert Person has to be a string. metalktoRobert Robert says: Have to run for lecture! metalktoAlbert Albert is not here. if typeperson str: printPerson has to be a string. return None # Replace this line #RQ def takeself thing: Take a thing if thing is at player's current place hotdog ThingHotdog 'A hot looking hotdog' bcc PlaceBCC 'You are at Bearcat Cafe', hotdog me PlayerPlayer bcc mebackpack metakehotdog Thing should be a string. metakedog dog is not here. metakeHotdog Player takes the Hotdog metakeHotdog Hotdog is not here. if typething str: printThing should be a string. return None # Replace this line def checkbackpackself: Print each item with its description and return a list of item names. cookie ThingCookie 'A huge cookie' donut ThingDonut 'A huge donut' cupcake ThingCupcake 'A huge cupcake' bcc PlaceBCC 'You are at Bearcat Cafe', cookie donut, cupcake me PlayerPlayer bcc mecheckbackpack In your backpack: there is nothing. metakeCookie Player takes the Cookie mecheckbackpack In your backpack: Cookie A huge cookie Cookie metakeDonut Player takes the Donut food mecheckbackpack In your backpack: Cookie A huge cookie Donut A huge donut food Cookie 'Donut' printIn your backpack: if not self.backpack: print there is nothing. else: for item in self.backpack: print item.name, item.description return itemname for item in self.backpack class Characterobject: def initself name, message: self.name name self.message message def talkself: return self.message class Thingobject: def initself name, description: self.name name self.description description class Placeobject: def initself name, description, characters, things: self.name name self.description description self.characters charactername: character for character in characters self.things thingname: thing for thing in things self.exits # name: exit 'description' def lookself: printYou are currently at self.name You take a look around and see: printCharacters: if not self.characters: print no one in particular' else: for character in self.characters: print character printThings: if not self.things: print nothing in particular' else: for thing in self.things.values: print thing.name, thing.description self.checkexits def exittoself exit: if typeexit str: printExit has to be a string. return self elif exit
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
