Easy Question

  • Thread starter Thread starter Mark Cooney
  • Start date Start date
M

Mark Cooney

Ok

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?
 
Ok

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?

A simple way is to use a shared property in the Game class that keeps
a list of Game instances using a key/value pair. Store the GameID of
an instance as the key, and the actual instance as the value. Then a
simple if MyGameList.Contains(myGameId) then... should give you the
functionality you require.

Thanks,

Seth Rowe
 
If myGame Is Nothing orElse myGame.GameID <> runningGameID Then
myGame = New Game
myGame.GameID = runningGameID
End if

'Update other properties of myGame
 
Ok

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?

Hi

Could you tell me please how did you make a functions which runs every
6 seconds ??
I need to do somthing similar in my project.

Thanks
Yhlove
 
Yhlove,

Please don't ask questions connected to another question. It makes it
confusing for those who are searching this newsgroup as is often done using
Google. This is a 7 days a week 24 hours newsgroup done by people all over
the world so your answer will be there if it is known.

Cor
 
Just wanted to say you can safely ignore Cor's reply. The newsgroup does
not exist to make Google happy, nor does it exist to support the needs of
some unknown number of people who at some unnamed point in the future
require some unknown piece of information.

If you have a question, post it as you've done. Thread topics migrate all
the time, not only this week but for the more than 520 weeks I've been
contributing to them.
 
Mark Cooney said:
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
 
Thanks all

I did a figure a way to do thanks to rowe and stephany and a mixture of both
ways . and yh, just for your info i used a timer set to 6000.
 
Back
Top