| Author |
Getting from another class.
|
Martin vanPutten
Ranch Hand
Joined: Mar 26, 2006
Posts: 124
|
|
|
What is the easiest way to get something from another class in the project and using it in the class you want. For example: currentRoom is an object of Room in the Game class. There is another class called Player... and the player object has to store the currentRoom in the Game class. And... this has to be done in the Player class... its necessary. Whats the easiest way to do this? Even Pseudo code will help as long as the keyword used is in it because chances are, I don't know it. Thanks!!
|
Live And Let Learn.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9948
|
|
Write a method in the Game class called getCurrentRoom() that returns a Room. If you are in Player, then you need a reference to the Game class. if you are in some other code, you could write a putCurrentRoom() in the Player class, then do Room tempRoom = myGame.GetCurrentRoom(); currentPlayer.putCurrentRoom(tempRoom);
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: Getting from another class.
|
|
|