Hey, I'm very new to programming and I just recently starting programming using Eclipse and I've having some trouble getting my array to print String as opposed to addresses. I haven't messed around too much with arrays so I think some of you may be able to point out where I went wrong fairly quickly.
I'm making a small text based RPGWhen the player chooses to start the game I have it print out the description of the part of town they're in and the exits they can choose from, however when it prints the result is:
Exits@1dd7056 Exits@fa3ac1 Exits@276af2 Exits@1de3f2d
Here is my code so far that is related to the Array of Exits:
---------------------------------------------------------
---------------------------------------------------------import java.util.ArrayList; public ArrayList<Exits> Exits = new ArrayList<Exits>(); public Exits(String dir, Room room) <--- dir is the String that tells the player where that exit leads to { Direction = dir; Room = room; <-- Room is what room the player is in. } Exits ToMageQuarters = new Exits( "Exit", MageQuarters ); Exits ToMarketPlace = new Exits( "Exit to Market Place", MarketPlace ); Exits ToMilitaryAcademy = new Exits( "Exit to Military Academy", MilitaryAcademy ); Exits ToMainGate = new Exits( "Exit to Main Gate", MainGate ); Exits ToAbandonedGhetto = new Exits( "Exit to Abandoned Ghetto", AbandonedGhetto ); Exits ToTownCenter = new Exits( "Exit to TownCenter", TownCenter ); Exits ToSWoutskirts = new Exits( "Exit to South West Outskirts", SWoutskirts ); Exits ToSEoutskirts = new Exits( "Exit to South Eest Outskirts", SEoutskirts ); Exits ToNEoutskirts = new Exits( "Exit to North East Outskirts", NEoutskirts ); TownCenter.Exits.add(ToMageQuarters); TownCenter.Exits.add(ToMarketPlace); TownCenter.Exits.add(ToMilitaryAcademy); TownCenter.Exits.add(ToMainGate);
Now when I go and try to get it printed out to the console I do:
---------------------------------------------------------for( int i = 0; i < currentRoom.Exits.size(); ) { System.out.println( currentRoom.Exits.get(i) ); i++; }
Any help would be highly appreciated. Sorry of the mistake is obvious I'm still a very new programmer.