473,473 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

running a class a particular number of times

1 New Member
hey
can some please tell me how to run this class a specific number of times. maybe by using a for loop?.
i am making a game called memory game where you match the cards which are the same. i want to make this a multiplayer game rather than a single player game. Thus in order to do this i need to be able to run the class (shown below) a specific number of times.

i have an array called "players" which is a length of 5. and if the user enter the names into all five elements or there are 5 players then i need the program to run 5 times. else if the user only entered a name in two elements then i need the class "MemoryMatch" to run twice .

i know how to determine whether the user entered 5 names or a single by using if statements. but i dont know how to make the class "MemoryGame" run a specific number of times.

.. .and for the game i calculate the score of the user by finding the amount of time it takes the user to finish the game and then subtract the time they took from a base value of 500 points. i then put the time difference into an array called "timez" i also want the class to add the time to array "timez" at the end after the one of the players has finished the game or the class is run.

below i have the whole code for my program


website for code

thanks
Jun 8 '07 #1
2 1335
blazedaces
284 Contributor
hey
can some please tell me how to run this class a specific number of times. maybe by using a for loop?.
i am making a game called memory game where you match the cards which are the same. i want to make this a multiplayer game rather than a single player game. Thus in order to do this i need to be able to run the class (shown below) a specific number of times.

i have an array called "players" which is a length of 5. and if the user enter the names into all five elements or there are 5 players then i need the program to run 5 times. else if the user only entered a name in two elements then i need the class "MemoryMatch" to run twice .

i know how to determine whether the user entered 5 names or a single by using if statements. but i dont know how to make the class "MemoryGame" run a specific number of times.

.. .and for the game i calculate the score of the user by finding the amount of time it takes the user to finish the game and then subtract the time they took from a base value of 500 points. i then put the time difference into an array called "timez" i also want the class to add the time to array "timez" at the end after the one of the players has finished the game or the class is run.

below i have the whole code for my program


website for code

thanks
??? Sorry, I'm a bit confused.

In your program you initiate a bunch of JPanels or JButtons or whatever, another words you use more then one of a class!

So what are you asking about?

Your extending JFrame. I don't know the exact syntax for the GUI's but maybe you need to extend it as a JComponent, then in a program on top of that, make 5 of them, and add them into a layout just like you did in this class...

If this is not what you mean, even though you're pretty specific about it then please say so...

If you want more then 5 you can make as many as you want and add them in a pattern... I don't know, this isn't a complicated problem, I don't think.

I hope this helped man, and good luck,

-blazed
Jun 9 '07 #2
dmjpro
2,476 Top Contributor
hey
can some please tell me how to run this class a specific number of times. maybe by using a for loop?.
i am making a game called memory game where you match the cards which are the same. i want to make this a multiplayer game rather than a single player game. Thus in order to do this i need to be able to run the class (shown below) a specific number of times.

i have an array called "players" which is a length of 5. and if the user enter the names into all five elements or there are 5 players then i need the program to run 5 times. else if the user only entered a name in two elements then i need the class "MemoryMatch" to run twice .

i know how to determine whether the user entered 5 names or a single by using if statements. but i dont know how to make the class "MemoryGame" run a specific number of times.

.. .and for the game i calculate the score of the user by finding the amount of time it takes the user to finish the game and then subtract the time they took from a base value of 500 points. i then put the time difference into an array called "timez" i also want the class to add the time to array "timez" at the end after the one of the players has finished the game or the class is run.

below i have the whole code for my program


website for code

thanks

Welcome to TSDN.
To run a class file means a particular methods gets called.
Right?
So create an Object reference of that class and call that particular method when ever u want.
Right?
Best of luck.

Kind regards,
Dmjpro.
Jun 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: noise | last post by:
Hello, I have problem with drawing running graph. What I want to draw is: I have an object O which as a real number r associated with it. In the main() (in main class) i have a for loop which do...
2
by: Bob Murdoch | last post by:
I'm developing an intranet application using W2k server and IE5.5 - 6.x clients. I've got one particular function that calls a stored procedure to update a number of records, depending on user...
41
by: AngleWyrm | last post by:
I have created a new container class, called the hat. It provides random selection of user objects, both with and without replacement, with non-uniform probabilities. Uniform probabilities are a...
2
by: Xiangliang Meng | last post by:
Hi, all. What will we get from sizeof(a class without data members and virtual functions)? For example: class abnormity { public: string name() { return "abnormity"; }
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
5
by: vj | last post by:
Hi all, I am using C++Builder-5. I want to run multiple cpp files at the same time. If I use the C++Builder for running a cpp file (i.e., I just double click the cpp file, it then opens in the...
18
by: Ann Scharpf via AccessMonster.com | last post by:
I am not sure which would be the best place to post this question, so I'm posing it here with Access general questions. I have reached the point many times in Word and in Access where my ignorance...
5
by: edd | last post by:
Hello all, Please consider: template<typename Tclass my_class; template<class my_class<int> { //... };
4
by: AndrewD | last post by:
Hey C++ folks, I created this today, just for fun. You can make object allocation for any class around 6 times faster, simply by doing the following. class MyClass : public...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
1
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.