I have a super class called character, subclass player.
when i compile, i get this error:
constructor Room in class Room cannot be applied to given types;
from this bit of code in Character:
public Character(Room room, String name) this.name=name; currentRoom = room; Room currentRoom = new Room(); // here is the problem
the thing is that Room needs arguments to be passed to it (description for the constructor)
the problem is that i need to use an insttance of room "currentRoom" instansiatied from the main class Game,
following a similar post from before, the solution is to pass an instance of Game to Character, and then
call a method from Game in Character.
My problem is that Character is an Abstract class, so the player and (enemy or whatever) is gonna use the current room
plus, I will have the same problem for all the other classes, and it would seem like a bad programming practice to have
two methods for every task I want (one in Game, and the other in Character).
i ran the program without initializing Room in character, and when i typed command look, this is the code from Player:
public void look(Command command)
if(command.hasSecondWord()) // an error message if there was a second word System.out.println("You can't enter a second with look"); System.out.println("Look is used to know what room you are in, the exits and the availabe items"); return; else System.out.println(currentRoom.getLongDescription()); ---- problem in here System.out.println(currentRoom.listOfItems());
because currentRoom is not defined in Player?
i guess I have serious problems in understanding inheritance and OOP! any help will be much appreciated!
Thank you for your time!