+ 1

When to use class

hi, so recently I've been doing some code when i somehow confused should i use array only or use class for shop's items...could anyone tell me which is better to use? I'll be adding items in the shop someday

16th Feb 2017, 2:56 AM
Amrin Jaffni
Amrin Jaffni - avatar
5 Answers
+ 2
You may use these both. class Item { String name ; int amount ; double price ; // any property what you want ... } Item [ ] items ; if java, You may use the Map also Map <String, Item> map;
16th Feb 2017, 4:45 AM
K.C. Leung
K.C. Leung - avatar
0
so, there is something that i can use to add index in the array right? something like item.push??
16th Feb 2017, 5:47 AM
Amrin Jaffni
Amrin Jaffni - avatar
0
depends on which language are you using
16th Feb 2017, 6:12 AM
K.C. Leung
K.C. Leung - avatar
0
i see, thanks!
16th Feb 2017, 6:13 AM
Amrin Jaffni
Amrin Jaffni - avatar
0
if you want to add bulk of details under one name or in one guidance. then we can you class
22nd Feb 2017, 10:56 AM
sanjay
sanjay - avatar