In this exercice, you'll have to implement a function to add a product to the consumer'shopping cart.
You'll have to use the following structures:
typedef struct
{
unsigned int price;
char * name;
} stuff_t;
typedef struct
{
stuff_t ** bag;
char * name;
unsigned int bagSize;
unsigned int total;
unsigned int budget;
char** dontLike;
unsigned int size;
} consumer_t;
The client has by default a bag (bag) of size bagsize filled with empty items (stuff_t) (represented by NULL).
The bag acts as a stack, thus items added to the bag should be put just after the last item bought.
The variable dontLike is an array of size size containing char* representing the name of items that the consumer doesn't like.
We ask you to write a function called AddStuff.
Examples of use:
Let's suppose a consumer called Maximus, with a bag of size 10 and a budget of 5000, moreover this consumer doesn't like "salad" nor "fish" (dontLike = ["salad", "fish"]).
AddStuff(client, "teddy bear", 10);add to Maximus' bag the "teddy bear" item. There is thus 1 "teddy bear" and 9 empty items in his bag, with a total cost of 10.AddStuff(client, "salade", 5);add nothing to Maximus' bag beacuse he doesn't like salad. There is thus 1 "teddy bear" and 9 empty items in his bag, with a total cost of 10.AddStuff(client, "TV", 200);add to Maximus' bag the "TV" item. There is thus 1 "teddy bear", 1 "TV" and 8 empty items in his bag, with a total cost of 210.
INGInious