HELP please…

Updated on November 27, 2017 in [C] Beginner
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on November 27, 2017

okay so for my assignment I have 6 products that I have to sell… I already did all of the program but I’m stuck now because of arrays. This are my professor’s instructions: “Use an array of structures to store the items available for sale and their details, and another separate array of structures to record what was bought.”

I just started to learn all of this so I’m pretty new on all of this.. I just want to understand what he means by that.

I would appreciate if anyone could help me with this.. It’s with C# by the way.

  • Liked by
  • Masa
Reply
0 on November 27, 2017

Well, I would just create an own class like “Item” in which I define everything I want to store. Like:

string itemName

sprite image

float price

int availableCount

int purchasedCount

 

And then create in another script a list of items.

So this list<Item>

Then you can refer to that and if somebody bought a Item you just count up the purchasedCount and reduce the availableCount if he has enough money.

 

  • Liked by
Reply
Cancel