|
Quote:
|
|
I feel like I'm doing everything wrong.
|
You made a few mistakes, but your learning. If you already knew how to do it right you wouldn't be taking the class.
Was the code you posted part of the assignment or is that what you've come up with? (so we know what we can and can not do).
I see a few syntax errors in it, which lead me to believe it is your work, though you may have just copied it down wrong.
Instead of using parallel arrays, I would use a map of the name of the item and an array carrying the amount of items and the cost.
But if that is the code your instructor provided then you probably have to use parallel arrays as fubarable stated.
|
Quote:
|
|
If I was able to use more than one class, just out of curiosity, how would I go about doing that exactly?
|
You would create an Item class which could contain the price of the item.
You would also create a Slot class which would contain arrays of Items.
for example
|
Code:
|
double snickersPrice = 0.75;
Slot slot1 = new Slot("Snickers");
slot1.add(new Item(snickersPrice); |