Results 1 to 7 of 7
- 04-20-2012, 12:53 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 90
- Rep Power
- 0
how can I draw remaning cards in the array deck.
I want to draw 86 cards this is the rest of cards of 104, I have draw 20 random cards on the applet, please help me my code is.
Java Code:public void paint(Graphics g) { //System.out.println("paint"); super.paintComponents(g); // Required g.drawImage(Casino_table_img, 20, 20, this); try { for(int j =0; j <10; j++) { System.out.println(j); System.out.println("ok"); int randomPosition = rgen.nextInt(cards.length); ShowCard c = _deck[randomPosition]; g.drawImage(c.image, x1[j],y1[j], this ); g.drawImage(c.image,x2[j],y2[j], this); g.drawImage(img1,x2[j],y2[j], this); } int randomPosition = rgen.nextInt(cards.length); ShowCard c = _deck[randomPosition]; g.drawImage(c.image, x3[0],y3[0], this ); } catch (Exception e) { System.err.println("Caught IOException: " + e.getMessage()); } }//end paintComponent
- 04-20-2012, 01:01 PM #2
Re: how can I draw remaning cards in the array deck.
Apparently continued from Paint methode is running four times, I dont know why,
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-20-2012, 01:04 PM #3
Re: how can I draw remaning cards in the array deck.
Please explain what the posted code is doing that you want to change and explain what you want the changed version to do.
If you don't understand my response, don't ignore it, ask a question.
- 04-20-2012, 01:08 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 90
- Rep Power
- 0
Re: how can I draw remaning cards in the array deck.
My code is posted in #1 , now want to only draw my 86 cards, because my 20 random cards I have already draw. I dont know how will be draw and what will be the code for this, so please help me to find out my problem.
- 04-20-2012, 01:13 PM #5
Re: how can I draw remaning cards in the array deck.
The logic to chose the 20 cards to be displayed should NOT be in the paint method. You should determine what is to be displayed somewhere else in the code, save that info some where that paint can find it and then call repaint(). Then the paint method can get the info about what it is to do and do it.
Where is there a list of the 86 cards you want the paint method to draw?want to only draw my 86 cardIf you don't understand my response, don't ignore it, ask a question.
- 04-20-2012, 01:54 PM #6
Member
- Join Date
- Apr 2012
- Posts
- 90
- Rep Power
- 0
Re: how can I draw remaning cards in the array deck.
Ok,
I will try the above changes ...........
I have draw 20 of 104 so the remaining 86 cards I want to draw, I have draw random 20 cards each 10-10 cards is draw in different location, so I have not have a list that contained 86 cards-
My logic is those 20 cards I am displaying, It will be remove from array of 104, after display, and store in a different array, now the available 86 cards will be store in the array, after that I will show it, hence please give me the code how I can remove the 20 cards from the array of 104 after display, please help me.......
- 04-20-2012, 02:05 PM #7
Re: how can I draw remaning cards in the array deck.
You can not determine when the cards will be displayed in the paint or how often. You need to remove the cards from the list outside of the paint method.how I can remove the 20 cards from the array of 104 after display
How does the code determine which 20 cards to remove? When "removing" an element from the array, do you need to change the size of the array so that it is still full but with fewer elements? It would be better to use an arraylist so you do not need to worry about empty slots or changing the size of the array. An arraylist has a method to remove an element from the arraylist.If you don't understand my response, don't ignore it, ask a question.
Similar Threads
-
Tryin to create a deck of cards
By mrbrendano in forum New To JavaReplies: 6Last Post: 08-03-2011, 05:32 PM -
Help with creating a deck of cards
By Carouselification in forum New To JavaReplies: 5Last Post: 03-06-2011, 04:45 AM -
Deck of cards problem
By VelvetMirror in forum New To JavaReplies: 2Last Post: 02-16-2011, 08:02 PM -
Deck of Cards
By khunmato in forum New To JavaReplies: 13Last Post: 09-06-2009, 05:47 PM -
Problem with making/sorting a deck of cards
By Franneldort in forum New To JavaReplies: 9Last Post: 11-07-2008, 12:47 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks