Results 1 to 4 of 4
- 07-31-2013, 08:53 PM #1
Member
- Join Date
- Jul 2013
- Posts
- 2
- Rep Power
- 0
How to get multiple instances of an object/class
Hello, so I have an application where 2 players can enter into a 1v1 and then before the 1v1 starts they have 1 minute to bet a certain amount of money based off how much they think they will win, so there can be multiple 1v1's happening at one time so I need to be able to keep track of all the players and the amount of money they bet so that the winner can receive all the money.
So I determined that the best way to do this was to create a 1v1 class but I do not know how I would keep track of all the different 1v1's going on at one time, when a player adds a bet, I need to be able to find the correct 1v1 (that contains the 2 players name) and increase the bet amount for that bet and not everyone's bet. And when 1 player dies I need to be able to find the correct instance of the class that contains that player's name.
Right now I have it so when a player accepts a 1v1 request it passes the following data to the class
Java Code:OneVsOne ovo = new OneVsOne(p1, p2, betting);
Java Code:ovo.randomClass();
Thanks,
Ethan
(Also I have no idea if this would belong in 'Advanced java' or not) :\
- 07-31-2013, 10:29 PM #2
- 07-31-2013, 10:34 PM #3
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: How to get multiple instances of an object/class
So basically you don't know how to set a value in an object.
Well, then its time to open up your Java book and start at chapter one."Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 08-04-2013, 02:40 AM #4
Member
- Join Date
- Jul 2013
- Posts
- 2
- Rep Power
- 0
Re: How to get multiple instances of an object/class
I understand how to pass values to an object, but for all I know there could be 1 of these objects called, or 100. So I need to know how to figure out which object instance I have to use.
So there would be multiple instances of the same object, is it possible to iterate through all of the instances and check which contains which values?Last edited by xEthan; 08-04-2013 at 03:01 AM.
Similar Threads
-
How to paint multiple instances of class?
By Zigster in forum AWT / SwingReplies: 5Last Post: 05-29-2012, 05:32 PM -
Multiple object instances in array of objects
By Drizzt in forum New To JavaReplies: 6Last Post: 01-12-2012, 05:07 PM -
Multiple GUI Interface Instances
By mutagen in forum AWT / SwingReplies: 2Last Post: 03-19-2011, 04:06 PM -
Drawing multiple instances of one class with an array
By Grimmjow in forum New To JavaReplies: 16Last Post: 05-22-2010, 04:51 AM -
Problem calling multiple instances of a class
By virex in forum New To JavaReplies: 1Last Post: 03-02-2010, 04:03 PM
Bookmarks