Re: grouping different kinds of food

From: news.hku.hk (billychu_at_hkusua.hku.hk)
Date: 04/25/04


Date: Sun, 25 Apr 2004 23:15:00 +0800

just to add some points,
food[6].showname(); //may return banana
food[7].showname(); //may return pear
and so on ..........
i mean, we don't know how many kinds of food are there and their total
amount. So it's not possible to inherit the class with "known" names.
Thanks for your attention.

"news.hku.hk" <billychu@hkusua.hku.hk> wrote in message
news:408bc292@newsgate.hku.hk...
> I would like to group different kinds of food.
> There are unknown number of kinds of food e.g. apple, orange, lemon,
melon,
> ........
> of course it's only a finite number but i don't know.
> also suppose apple will have different price for different objects.
>
> i have a class food such that:
>
> food[1].showname(); //return string apple
> food[2].showname(); // return string orange
> food[3].showname(); //return string lemon
> food[4].showname(); //return string apple
> food[5].showname(); //return string orange
> //some more up to food[100].showname();
>
> food[1].showprice(); //return integer value 13
> food[2].showprice(); // return integer value 21
> food[3].showprice(); //return integer value 19
> food[4].showprice(); //return integer value 20
> food[5].showprice(); //return integer value 11
> //some more up to food[100].showprice();
>
> what i want to do is to output the total price for different food like
this:
>
> apple: 23
> orange: 32
> lemon: 19
>
> could you tell me how to do this ??
>
> Thanks a lot
> Regards,
> Billy
>
>



Relevant Pages

  • Re: OT: SF and Organic Veggies
    ... > won't buy ugly tomatoes at the supermarket (to head off anyone who is ... There are so many apple varieties that have been lost ... > to control what is in the food that I eat. ...
    (rec.arts.sf.tv.babylon5.moderated)
  • Re: CrockPot Apple Butter Dilemma
    ... > CROCK POT APPLE BUTTER ... Inc. 1995 based on THE FOOD ... LOVER'S COMPANION, 2nd edition, by Sharon Tyler Herbst. ... One says " A cooked puree " The other does not! ...
    (rec.food.cooking)
  • Re: grouping different kinds of food
    ... > There are unknown number of kinds of food e.g. apple, orange, lemon, melon, ... > also suppose apple will have different price for different objects. ... typedef unsigned int UINT; ...
    (comp.lang.cpp)
  • grouping different kinds of food
    ... I would like to group different kinds of food. ... There are unknown number of kinds of food e.g. apple, orange, lemon, melon, ... food.showname; // return string orange ...
    (comp.lang.cpp)
  • Re: CrockPot Apple Butter Dilemma
    ... Inc. 1995 based on THE FOOD ... LOVER'S COMPANION, 2nd edition, by Sharon Tyler Herbst. ... A cooked puree of apples, ... Your l info says that apple butter has cider ...
    (rec.food.cooking)