473,497 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Easy Question

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?
Feb 24 '07 #1
7 1010
On Feb 24, 2:48 am, "Mark Cooney" <m...@mcooney.co.ukwrote:
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

Feb 24 '07 #2
If myGame Is Nothing orElse myGame.GameID <runningGameID Then
myGame = New Game
myGame.GameID = runningGameID
End if

'Update other properties of myGame
"Mark Cooney" <ma**@mcooney.co.ukwrote in message
news:%2*****************@TK2MSFTNGP06.phx.gbl...
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?
Feb 24 '07 #3
On Feb 24, 9:48 am, "Mark Cooney" <m...@mcooney.co.ukwrote:
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

Feb 24 '07 #4
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

<yh****@gmail.comschreef in bericht
news:11*********************@z35g2000cwz.googlegro ups.com...
On Feb 24, 9:48 am, "Mark Cooney" <m...@mcooney.co.ukwrote:
>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

Feb 24 '07 #5
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.

<yh****@gmail.comwrote in message
news:11*********************@z35g2000cwz.googlegro ups.com...
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

Feb 24 '07 #6
"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
Feb 24 '07 #7
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.
"Tom Leylan" <tl*****@nospam.netwrote in message
news:uF**************@TK2MSFTNGP06.phx.gbl...
"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


Feb 25 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2201
by: rdsteph | last post by:
I am having a lot of fun using the pyGoogle module ( http://pygoogle.sourceforge.net/ ) that uses the Google API. It is about as easy to use as I can imagine, and it is a lot nicer than using my...
0
1359
by: | last post by:
I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts. So please help me! I have 2 tables: id | name ----------- 1 | thing1 2 | thing2 3 | thing3 4 ...
5
1517
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one...
1
4903
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
13
1462
by: Ghislain Tanguay | last post by:
I have a compiled vb.net app and I want to give the user a choice to launch it from the start line command and pass it a parameter or not. How can I do that in my code? Is it possible? Ex. :...
1
1470
by: melanieab | last post by:
Hi, If there's a textbox and the text entered is longer than what's visible (the textbox length), how do you make it so that the beginning chunk of text is visible (instead of the last part of...
23
2393
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
6
2275
by: Martin Bootsma | last post by:
I have a C question, which looks very easy, but no one here seems to know an easy answer. I have a function "powell" (from Numerical Recipes) which takes an argument of the type "double...
27
2260
by: smnoff | last post by:
How does( or should user use) strncpy() to allocate enough memory space for the destination string, s1? I guess I am having trouble using strncpy as it seems to be giving me errors. And just...
9
1883
by: rynTAU | last post by:
This is an easy question, I'm sure but I can't seem to figure it out. I'm trying to use the number_format() function to remove all decimal places from a number. $num = number_format($num,...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6881
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.