"Mark Cooney" <ma**@mcooney.co.ukwrote:
I have a class called Game which has an GameID value.
I also have a routine that runs every 6 seconds. I need to see if the
object Game exists with an GameID value = to the value of the Game that is
currently running, if it is i need to update values within that object if
not create a new object.
Any easy code?
Mark: There isn't quite enough information.
Are there multiple games running (which is what it sounds like to me)? If
that is the case then what is missing is another Class/Object which is a
game manager. Seth alludes to a solution but I think it would be a mistake
to add such a list to the Game class. A game isn't a collection of games.
And surely you will add methods and properties to a GameManager class which
have no business being in a Game object.
The GameManager would instantiate new games, remove old games, monitor games
and should even take care of your 6 second notification (with the value 6)
being a property of the GameManager so you could change it without editing
the Button Click event that contains a hard coded 6.
Now that you have a GameManager class you have the ability to create
multiple GameManager objects if necessary.
Tom