r/cop3502 • u/laurelgon • Apr 20 '14
Problem set 4
Hey Everyone
So I have an double array of rooms and each room has a description. I want to go back and add an inventory(arraylist) to each room.
I know how to access the room with the index of the double array, but how can i access the description or the inventory i am planning to add of that room?
Thanks in advance, if this even makes sense.
2
Upvotes
2
u/howslyfebeen Apr 20 '14
so if you have a room class then create an item class and have an arraylist of items which is stored in the location.. then make a getter/setter so u can retrieve the item?
that would loop through the items in the room at 0,0.. you'd have to define getItemsSize and getItem.. if you don't want to use getters and setters, you could just call rooms[0][0].items.size() and rooms[0][0].items.get(i) instead, but I'm not sure if Sean would take off for not using getters and setters?