#having trouble with items.
1 messages ยท Page 1 of 1 (latest)
Here is an AI assisted attempt to answer your question ๐ค. Maybe it helps! In any case, a human is on the way ๐. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
It sounds like there may be an issue with how you are adding the items to the rooms. Make sure that you are properly initializing the items in the room class and then adding them to the room object in your main program.
Double check that you are calling the correct methods to add the items to the room and that you are not accidentally overriding them with null values somewhere in your code.
Additionally, ensure that when you are displaying the items in the room, you are accessing them correctly from the room object.
If you are still having trouble, consider debugging your code by printing out the values of the items and rooms at various points in your program to see where things may be going wrong.
It might also be helpful to get a fresh pair of eyes on your code by asking for help from fellow developers on the discord server or posting your code for review. Sometimes a different perspective can help identify issues that may have been overlooked.
@vernal ferry you probably don't want to share this
whys that
I mean, if you are fine with leaking your name, it's not a problem I guess
I uploaded your attachments as Gist.
Same here
I uploaded your attachments as Gist.
ur still having issues with wrong responsibilities in ur class
all of this here makes no sense to put into the Room class
see, with that setup, each room that u create, for example a bathroom, will contain a Game, contain a second room called currentRoom, contain outsideItems, mainItems, officeItems,....
that's for each room that u have
so if u create 10 rooms, u have 10 games, 10 currentRoom, 10 outsideItems, 10 mainItems,...
that's just incorrect. not what u want
Room is the perspective of a single room. not the perspective of the manager of rooms
how would i list the the items ive added to the arraylists then?
not in the room class
a room may have a List<Item> myItems
but not lists of items for any room in the game
like, why would all ur rooms maintain lists of all rooms in the game
a room has to maintain its own items
not the items of everyone else
so do i keep that in game class?
u as a person have ur own money bag. and not one billion money bags of everyone else on earth
yes, all that stuff goes to whoever manages rooms
which is likely Game
so what type of stuff would i specifically include in the classes
so what should room class include?
room includes whatever makes up a room
describe what a room has and can do
a single room
it has a description. it has exits to other rooms. it has a list of items
so. add these 3 things
done
hmm alright
and one last thing am i overusing these questions posts or is this how its meant to be used?
nah ur fine. its how its keant to be used ๐ feel free to make a million threads
๐
alright thank you very much
where should something like a pickup command be then
in the player class
or game (main class)?
and is there some sort of video that goes other this structuring stuff?
probably most OOP videos. it's more about understanding what a class is
what would that method do? take an item from the room and add it to a players inventory? probably in the game i guess
while room then has a method to remove an item from its list and player one to add an item
i have inventory class i said player instead sorry
an inventory definitely won't deal with rooms
inventory should offer methods to adf/remove items
but not have anything to do with a room
inventory should offer a method to add an item to it. but it should not have a method "ill pickup an item from a room"
someone else decides where the item is taken from
not inventory
ur money bag also doesn't execute a transfer from ur bank account. that's u who does that
not ur bag
ur bank offers a method to deposit. ur bag a method to put money into it. but u, the human, has the method to "takeMoneyFromBankAndPutItIntoBag"
then im just gonna end up moving everything to game class, is that not bad?
everything? no, only the stuff that shouldnt belong elsewhere
and yes, if ur game class keeps growing u should split responsibilities further
well if i move pickup etc there then am putting most of the responsibilty on the game class
well. first of all u need to move everything to the right place. cause right now it's not just a design/style issue but leading to a setup that makes no sense logic-wise and hence is impossible to get working without severe bugs
once thats done u can approach making it nicer
yh im having trouble understanding what should be where, how can i understand this or learn
perhaps u need to step back and consume some oop lessons and do exercises
i feel like u didn't fully grasp the purpose and responsibilities of a class
assignment due tmrw unfortunately
In particular since u keep adding stuff to them that is the responsibility of a manager of the class rather than what a single instance of it deals with
which then consequently ends up being impossible to get working
bc that's not how classes work
I uploaded your attachments as Gist.