• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cards game

 
Mona Alsh
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There ,,
I'm trying to solve one of the cards exercise questions using arrays and linkedList.
The question goes like this. modify the program to deal five- cards poker hand.
I'm try to store every 5 cards in an array and then add this array to the ArrayList.
when I print the list to check if it is correctly storing every 5 elements. I found that it just repeating
the same five cards from every ArrayList element

Card Class




DeckOfCardsClass



DeckOfCardsTest class







I'm concerned with the last class in which I should make the 5 cards in every ArrayList element!!
 
Carey Brown
Ranch Hand
Posts: 1543
18
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add a *new* hand array each time to the ArrayList. As it is you keep adding a reference to the same hand array each time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic