Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2012
    Posts
    90
    Rep Power
    0

    Default 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

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: how can I draw remaning cards in the array deck.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default 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.

  4. #4
    Join Date
    Apr 2012
    Posts
    90
    Rep Power
    0

    Default 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.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default 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.

    want to only draw my 86 card
    Where is there a list of the 86 cards you want the paint method to draw?
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    Join Date
    Apr 2012
    Posts
    90
    Rep Power
    0

    Default 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.......

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default Re: how can I draw remaning cards in the array deck.

    how I can remove the 20 cards from the array of 104 after display
    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 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

  1. Tryin to create a deck of cards
    By mrbrendano in forum New To Java
    Replies: 6
    Last Post: 08-03-2011, 06:32 PM
  2. Help with creating a deck of cards
    By Carouselification in forum New To Java
    Replies: 5
    Last Post: 03-06-2011, 05:45 AM
  3. Deck of cards problem
    By VelvetMirror in forum New To Java
    Replies: 2
    Last Post: 02-16-2011, 09:02 PM
  4. Deck of Cards
    By khunmato in forum New To Java
    Replies: 13
    Last Post: 09-06-2009, 06:47 PM
  5. Problem with making/sorting a deck of cards
    By Franneldort in forum New To Java
    Replies: 9
    Last Post: 11-07-2008, 01:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •