Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- From: "Cap'n Ahab" <space.invader@xxxxxxxxx>
- Date: 31 Dec 2005 06:14:55 -0800
Thanks for the responses, guys. The one that seems to make it work as
I originally planned is the change below...
Private _generator As New Random ---> Private Shared
_generator As New Random
However, this runs contrary to what I would expect! 180 degrees
wrong!!!!
I would have thought that the code in the constructor would create a
random number between 1 - 6 (which it does) but in addition it would be
a different value for every new object that is instantiated by the die
class as part of the Dim myObject as New Die command (but it doesn't).
Why do they have the same value? I thought if you wanted a value to be
common throughout instantiation of a class THEN you used the SHARED
command - not the other way round as happens here. Using shared makes
instantiations of the Die Class begin with, well, a different number
from each other.
I think this is more of my lack of understanding of how the Random
command works and not my appreciation of OO programming. Do you agree?
.
- Follow-Ups:
- Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- From: Joergen Bech
- Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- From: Cap'n Ahab
- Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- References:
- My FIRST Class!! But it doesn't work as expected - please HELP!
- From: Cap'n Ahab
- Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- From: Joergen Bech
- My FIRST Class!! But it doesn't work as expected - please HELP!
- Prev by Date: Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- Next by Date: Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- Previous by thread: Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- Next by thread: Re: My FIRST Class!! But it doesn't work as expected - please HELP!
- Index(es):
Relevant Pages
|