Guys and gals,
Please bear with me, because I've just taken the OO plunge and made my first class. It is a "die" class, used for gaming. I created a roll method and a constructor that requestes how many sides the die should have. I've also made a "dice" collection class. I was hoping to make a similar "roll" method that would create a new random value for each die in the collection. I thought that this would be written in the dice class as a function called roll with terminology something like:
That gives me enough errors that I now feel that is the wrong way to go. So, my question is, what is the syntax for a function in a collection class that needs to act on each of the members of the class?
The search engine for the site is down tonight so if this has been answered in the past, my apologies.
Thanks for the help,
Fred
Please bear with me, because I've just taken the OO plunge and made my first class. It is a "die" class, used for gaming. I created a roll method and a constructor that requestes how many sides the die should have. I've also made a "dice" collection class. I was hoping to make a similar "roll" method that would create a new random value for each die in the collection. I thought that this would be written in the dice class as a function called roll with terminology something like:
Code:
for each die in dice
... code here
next die
The search engine for the site is down tonight so if this has been answered in the past, my apologies.
Thanks for the help,
Fred