Currently learning Java
Fred Hamilton wrote:The code itself seems pretty neat and clean, but I'm more interested in what your thinking was when you made decisions of your data structure. Why use a hash map? Not saying it's a bad idea, but i'm interested in your reasons for designing it the way you did.
One other thing that would help would be an introduction or high level overview, not too technical, of what your program does. or how it simulates a real life vending machine. I could probably figure it out, but it's better to hear it from you
Michael Dunn wrote:vending machines have stock, snacks don't.
[edit]
should be a snack doesn't
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Michael Dunn wrote:> cause here stock refers to the supply (quantity on hand) of a particular snack.
yes, and that's part of the vending machine's job.
a snack doesn't hnow how many brothers and sisters it has
Michael Dunn wrote:(2nd attempt at post - mods please delete this if duplicated)
> it's really just a category with several types of snack, each type is an instance with a quantity
I'd probably create an InventoryItem (or VendingMachineItem) class, which would have a snack and a quantity.
the VendingMachine would then contain a collection of InventoryItems.
(you could have snack extend InventoryItem)
How about machine and product for the package names?Andrew Monkhouse wrote: . . . I would not have expected to have both the VendingMachine class and the Snack class in the same package. . . . one set of packages for "vendors", which could include VendingMachine, Store, Vendor, etc. I might then have another package for "salable" (terrible name - I would want to think about that)
Campbell Ritchie wrote:
How about machine and product for the package names?Andrew Monkhouse wrote: . . . I would not have expected to have both the VendingMachine class and the Snack class in the same package. . . . one set of packages for "vendors", which could include VendingMachine, Store, Vendor, etc. I might then have another package for "salable" (terrible name - I would want to think about that)
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Currently learning Java
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Currently learning Java
Currently learning Java
Don't get me started about those stupid light bulbs. |