Results 1 to 2 of 2
Thread: add objects to list
- 11-17-2009, 10:00 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 5
- Rep Power
- 0
- 11-17-2009, 10:11 PM #2
Eep you will be better off recreating your cards a different way. I'm not familiar with ENUMS but every example for a deck of cards uses them. I'm assuming you have 52 cards name faceValueOfDeck? Having it set up this way will require you to add each one individually to an array(or arrayList)
If you redo it and have 52 card objects you can have a for loop that creates them within the loop while adding them.
I'm sure you can work some better logic into to determine the face values(like x%13 == 0 then value = ace)Java Code:for(1 to 52){ if(x > 0 && x <= 13) if(x == 10) value = "jack"; else if(x == 11) value = "queen"; else if(x == 12) value = "king"; else if(x == 13) value = "ace"; else{ value = x; deck[x] = new Card("Clubs",value); } ....... }
Hope this helpsLiberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
Similar Threads
-
Finding objects in a list
By starwars in forum AWT / SwingReplies: 5Last Post: 09-11-2009, 03:42 PM -
List of objects
By bubbless in forum New To JavaReplies: 0Last Post: 08-01-2009, 04:21 PM -
List of objects
By rekha in forum New To JavaReplies: 6Last Post: 03-20-2009, 11:39 AM -
read txt file,with some records, create objects and store objects in tables of a db.
By stamv in forum JDBCReplies: 1Last Post: 01-22-2009, 04:25 PM -
Getting objects from a list
By markyoung1984 in forum New To JavaReplies: 4Last Post: 03-13-2008, 10:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks