Hello. VB6 and Excel 2003.
I would like to model dice throwing using OOP design principles. Initially this would be for a demonstration
but it could later be used be build a model. BTW I'm fairly new to OOP design.
Anyway, I think I need to create a (factory) constructor as, when a dice (die?) is instanciated a property (Sides)
should also be specified and validated to a reasonable range (2 to 12, say). I might also include a Colour property
and use enums (2 = Penny, etc.).
I will include a Throw method for each instance, but I would like use a Collection to throw several dice at once.
However, I'm not sure how to implement this. Should I implement the Collection as a separate class?
Ideally, the Throw method could apply to either an individual dice or to a collection of them - Polymorphism?
(I will use arrays to store the results of many Throws, for later input into Excel ranges.)
Anyway, any hints or guidance will be much appreciated. Andy.
Model dice throwing
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Model dice throwing
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78412
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Model dice throwing
Perhaps you'll get some ideas from Dice Class — Building Skills in Object-Oriented Design or from Object Oriented Programming Using VB.net 2008. Neither uses VB6 but the OOP aspects should be similar.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Model dice throwing
Thanks for your response. I'll have a look through these.
Andy.
Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.