+ 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
5 ответов
+ 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;
0
so, there is something that i can use to add index in the array right? something like item.push??
0
depends on which language are you using
0
i see, thanks!
0
if you want to add bulk of details under one name or in one guidance. then we can you class