Author | Message |
---|---|
OhWhen
Posts: 14
|
Posted 23:08 Feb 12, 2020 |
Hey, anyone understand how to add the data to each of the computer components? Like are we supposed to go through the inventory class to add them to the ArrayList or call it from their own classes such as Case, Monitor, etc. |
dkwok
Posts: 24
|
Posted 23:43 Feb 12, 2020 |
Like populating the inventory? If that's the question.. What I did was that I initialized the ArrayList through the inventory class then I populate each of the computer components through the main tester class using the add function that was created in the inventory's methods. Since the inventory class just a bunch of static methods that can be called by just doing something like: "Invenotry.addCase(whatever parameters);" Last edited by dkwok at
23:50 Feb 12, 2020.
|
kknaur
Posts: 540
|
Posted 15:43 Feb 13, 2020 |
You can create the individual objects somewhere in your Main/Tester class. I would probably have like a setupInventory method which does exactly that. Create 3 of each computer part type using the given part data and then call the addPartname method from the inventory class to add each part to its respective list in the inventory. Example: Case case1 = new Case(data for case 1); Inventory.addCase(case1); Then when you are ready to do your menu and have the user choose computer parts, all parts are stored in the Inventory class and you have everything in one place. |
OhWhen
Posts: 14
|
Posted 09:24 Feb 18, 2020 |
Im having trouble with using the second menu. My first scanner input is being used for the computer part option selector instead of my second scanner and is forcing an IndexOutOfBounds error |