Hey i have this java code for a text based videogame (its like Zork if you know what that is), but im having problems putting it into python. I've changed the parts I know and it starts to run, but then it comes up with random errors like that the Game instance doesn't have a currentRoom attribute. Please tell me if you have any ideas how to put the java code into python, how to make the python code run, or how to put new code from python into the java code? Thank you!!! :D
How Do You Change This Code to Python?!?
Collapse
X
-
Hi
I think you're going to have to give us more clues than that!
But a cursory look through suggests that the following might be things to look at/try:
1. At the end you run the program as follows:
This makes no sense to me. the currentRoom variable is clearly not used here.Code:newGame = Game() currentRoom = Room() newGame.play()
2. In the Game class, many class variables are set, but as far as I can see these are never used.
3. In the __init__ method of the Game class the first three lines are
The currentRoom variable is therefore only defined for the duration of the running of __init__. Intuitively I would guess that what is meant is:Code:self.io = Console() currentRoom = self.bedroom self.bedroom = Room("your familiar bedroom")
Unfortunately I don't have visual installed at the moment, but this change might make the difference. Or it might not... You'll have to let us know.Code:self.io = Console() self.bedroom = Room("your familiar bedroom") self.currentRoom = self.bedroom
Comment