Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Instances of a class huge problems

I'm a programming student, and most of what I did works, but I can't find any help on what my problem is and I haven't been able to figure it out by debugging either. The final project is due tuesday and this is going to kill my mark if I can't make it work.

I'm making a game in Java, using Ready to Program IDE if it matters. It's a card game, and my game class holds an array of players(another class of mine). Presently there are two players, but if i get it working I plan on expanding that.

I've tried it as both an array and two separate objects, and neither solves my problem.

The Player classes have a few subclasses within them. Namely a hand, a flight, and an ante.

The cards put into these come from my deck class, but when I run the program, I get two Identical players, and somehow adding to one of the Player objects adds to both. I'm running out of ideas and I can't figure out why it doesnt want to allow me to have two separate and different player classes in my program. It isnt drawing the same cards from the deck multiple times unless its a timing issue (which it doesnt seem to be) as after the card is drawn from the deck, the card is deleted and the deck size reduced by one.

If anyone can help me then I'd greatly appreciate it; you'd be helping me salvage my mark. Also, if anyone wants to see the completed program when it works I can send it to people. my email is rpmalon@gmail.com

I tried to upload the file but it resets my connection, so I'm suspecting it won't let me upload a 12M file.
[1639 byte] By [sylrae] at [2007-11-11 10:13:32]
# 1 Re: Instances of a class huge problems
I believe I have just had an epiphany. It was drawing the same cards because I was passing the dedck of cards to the players, but once passed, the players were drawing from a copy and nothing updated the original. it kindof makes you feel a bit like an idiot. I'm about to see if I can fix it.

--

Scratch that, I checked it, and it still doesn't work. It was updating the original deck and still giving me the problem with the player subclasses.
sylrae at 2007-11-11 22:31:51 >
# 2 Re: Instances of a class huge problems
Does anyone have a way to help me?

I attached all the code. The images aren't there, but the code is.

Somehow the Hands(withing the game class, accessed by interface)
and Flights, end up Identical, and changing one changes both. I need some help because this is driving me insane. Thanks
sylrae at 2007-11-11 22:32:52 >