Results 1 to 4 of 4
  1. #1
    carlos123 is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Cool a little help needed for card drawing

    i was told to write a program in java for a friend, i know almost nothing of java, and came here for help

    -i need a class that draws 1 card from a 52 card deck and displays the value of the card.

    -a class that will draw 5 cards from a deck of cards 9 A (single deck) and displays them.

    thanks in advance.

    again, im not a programmer, but any suggestions are helpful

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    8

    Default

    If a friend told you to write a program, knowing that you know nothing about the given language - well, that's just not a very thoughtful friend. An even better friend would be Head First Java by Kathy Sierra and Bert Bates.
    Last edited by CaptainMorgan; 01-09-2008 at 04:39 AM.
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  3. #3
    carlos123 is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default ty

    any other suggestions?

  4. #4
    carlos123 is offline Member
    Join Date
    Nov 2007
    Posts
    38
    Rep Power
    0

    Default

    Java Code:
    public class Random_Gen
    {
        int min;                     //minimum number that can be generated.
    	int max;                    //maximum number that can be generated. 
        int value;
    
    	public Random_Gen(int n, int m)
    	{
            max = m;		//code goes in this class
    	    min = n;
    	   
    	}
    	
    
    	public int getRandom()
    	{
    	 
          
    	    return value;
    	    
    	 }
    }
    public static void main(String[] args)
    	{
    	    int min = 1;                 // smallest number that can be generated
    	    int max = 20;                // largest number that can be generated
    	    Random_Gen  rg = new Random_Gen(min, max);
    	    int num;
    	    int[] frequency = new int[max];
    	    
    	    
    	    for (int x = 0; x < 10000; x++) 
    	    {
    	       num = rg.getRandom();
    	       
    	       System.out.println(num);
    	       
    	       for (int index = 0; index < max; index ++)     //determines frequency
    	          {
    	           if (num == index + 1) 
    	             frequency[index]++;
    	           }
    	     }
    	     
    	     
    	      for (int index = 0; index < max; index ++)     // displays frequency
    	    {
    	        System.out.println(""+(index+1) + " = " + frequency[index]);
    	    }

Similar Threads

  1. drawing window
    By BlitzA in forum New To Java
    Replies: 1
    Last Post: 01-15-2009, 01:55 PM
  2. Getting network card address in Java 6
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-02-2008, 08:10 PM
  3. Card program , need help thanks.
    By carlos123 in forum New To Java
    Replies: 2
    Last Post: 12-31-2007, 08:23 AM
  4. Drawing outside paintComponent()
    By DarkSide1 in forum Java 2D
    Replies: 2
    Last Post: 11-08-2007, 11:36 PM
  5. Help with Drawing a line
    By Rgfirefly24 in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 09:40 AM

Posting Permissions

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