Flex BlazeDS based Poker game

I am working on a Flex Java based poker game where multiple tables need to be created and people are placed on the tables depending on the table availability. I am facing issues adding people from resource pool to the tables. Any one worked on something similar? Any tutorials, examples or code snippets would be helpful.

Rjoshicool, I think people are misinterpreting your explanation (simply because of the crossover of terminology) and you are on the right track.
If I understand it correctly:
You have a multiple number of poker Games. These are Tournaments rather than individual games.
Each tournament has multiple poker tables associated with it and multiple players on each poker table. All players are associated with a tournament, game and table. This association is going to change over time and for the tournament as a whole.
Database tables:
You will need at least
A tournament table, a poker_table table, player table, game_table. You are going to need a load of other tables to hold information about anscillary items perhaps - for example there may be a league, poker_team, etc. I don't know.
In a multiple user system you need to take care of people disconnecting unexpectedly, wanting to get back to a game if accidentally disconnected, wanting to pause play, chat, etc.
Most importantly you must be able to prevent concurrent updates of the database tables since you have multiple players effectively updating the state of a game/table.
It can all get quite complex, quickly.

Similar Messages

  • Flex + BlazeDS

    Hello, friends!
    I'm new to both Flex and Java.
    I'm trying the most simple tutorials (
    http://www.adobe.com/devnet/livecycle/articles/blazeds_gettingstarted.html),
    and doing everything according, but I can't put the Flex working
    with the BlazeDS.
    I post my doubt on BlazeDS forum, but no one has even
    answered.
    The question is, when I run my MXML application, I can see
    through the Firebug that the 404 (not found) error occurs on "
    http://localhost:8080/myfirst/messagebroker/amf".
    Until now, I don't even know if the problem is on my MXML
    app, on my Java classes, on the config xml files or in my server.
    Does anyone know where could be the problem? Or could someone
    point out a beginners Flex + BlazeDS tutorial?
    Thank you,
    CaioToOn!

    http://localhost:8080/myfirst/messagebroker/amf
    is the servlet mapping that should be defined in web.xml
    make sure tomcat is running, blazeDS is deployed and most
    imporantly try accessing
    http://localhost:8080/myfirst/messagebroker/amf".
    with browser, if blazeDS is deployed you get blank page, if not
    than servlet and or/tomcat is not running
    based on url :
    http://localhost:8080/myfirst/messagebroker/amf".
    conclusions are following :
    you have webapplication context named "myfirst" deployed
    inside webapps directory of tomcat,
    (assuming you use tomcat).

  • Multithreaded Poker game *lost*

    Hi,
    I have an assignment in which I am to make a poker game, one server and four clients.
    "Up to 4 players should be able to connect to your server and play. All four players need to be logged into the server before cards are dealt.
    Players should have to enter their name and each player should be able to see all the players that are connected to the server.
    You can represent playing cards however you wish.
    You don�t have to implement betting, only logging into the server, cards being dealt, the draw and the determination of the winner.
    Server communication with the players and player communication with the server should be handled by separate threads."
    To be honest, I am lost. I just don't understand how it should work.
    Based on the example in the book, I created a server-client classes with client-thread.
    When the client connects, a gui window object is created from the client class.
    I can talk to clients, and clients can talk to me.
    I tried to echo the messages that I get from clients, so that the others can see what has been posted, but I can get it.
    Before I even start trying to create the game itself, I should know how to handle it.
    Can you please just explain to me where to start?
    I uploaded what I've got sofar. Can you please take a look? I am desperate :-(
    www.figuric.com/java/src.rar
    Thank you!

    Has anyone an idea, please?
    Thanks!

  • 2 player web-based Flash game problem

    I have a two player web-based Flash game. The Flash calls a
    JavaScript function on the webpage to get and store the user's IP.
    Then an XML file with user's game data is loaded and parsed. The IP
    address is used to identify which player is player 1 and which is
    player 2 according to the XML file. There is a Java applet to send
    and receive messages between the players.
    The first player loads everything just fine. All the first
    player's messages regarding the progress in loading different parts
    of the code sent by the game for debugging are displayed in the
    Java applet's text box, but none of the second player's messages
    sent by the game for debugging are displayed.
    The problem is that the second player's ActionScript code
    appears not to be executing except that I do get a message in the
    game that the XML file attempted to load but was not successful.
    The IP address call is not made and no messages can be sent to the
    other player. The second player's Java applet displays only the
    messages for debugging that came from the first player's game and
    any chat messages sent by the first player.
    This problem always happens to the second player, never to
    the first player. Both player's are always using IE6 or IE7.
    Does anyone have some idea(s) what could cause only the
    second player's ActionScript code not to execute and/or not to load
    an XML file correctly?
    This is just a general question, so any general answers would
    be appreciated. Code specific answers are hopefully not required.
    Thank You in advance.

    Hi,
    I am not very familiar with the multiplayer Game development. For multiplayer games, you'll need to set up a matchmaking server and have the clients connect to it. It can then pair them off and facilitate communications. If the clients have publicly available
    network addresses then it can introduce them and they can talk directly to each other.There isn't anything built in for this so you'll need to either build your own or find a third party implementation. If you are using Unity3d then check out
    http://docs.unity3d.com/Documentation/Components/net-MasterServer.html
    Also, you can use Xbox services, and I find an article below:
    https://msdn.microsoft.com/en-us/library/bb975801.aspx
    For windows Azure problem, you should go to windows Azure forum.
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How to get assettype of a flex asset based on asset id

    How to get assettype of a flex asset based on asset id

    See http://docs.oracle.com/cd/E29495_01/doc.1111/webcenter_sites_11gr1_bp1_developer_guide.pdf page 84:
    ASSETSET.GETASSETLIST retrieves an ordered list of assets, given optional sort criteria.
    The resulting list has two columns, assetid and assettype, that are sorted by the criteria that you specify.

  • Problem in RPC call (flex,blazeds,spring,H2,tomcat,eclipse)

    Hi, I've problem displaying value from backend onto the flex UI. I'm using Flex,BlazeDS, Spring, H2 in my applicaiton (testdrive app).  
    I've basically added another flex project to the testdrive app i downloaded. everything is working fine except the intended rpc invoke. 
    pls find the code snippets for the related change below :  
    1. FlexHelloWorld.mxml 
    private function resultHandler(event:ResultEvent):void 
    //used for debugging - shows details about result 
    //returned by the Java class method 
    Alert.show("success... in flex"); 
    Alert.show( ObjectUtil.toString(event.result) ); 
    <mx:RemoteObject id="ro" destination="helloServiceDestination" result="resultHandler(event)" fault="faultHandler(event)"/> 
    <mx:Panel x="25" y="10" width="653" height="407" layout="vertical" title="Test Flex 3 Using Java" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13"> 
    <mx:Text text="Click The Button To Test Getting Data Into Flex From A Java Class" fontWeight="bold" width="250"/> 
      <mx:Button label="Get Hello World Mesg From Java!" click="ro.getHelloWorld()"/> 
    </mx:Panel> 
    2. remoting-config.xml in flex 
    <destination id="helloServiceDestination" channels="my-amf"> 
         <properties> 
             <source>org.springframework.flex.samples.example.HelloWorld</source> 
         </properties> 
      </destination> 
    3. flex-servlet.xml in spring 
    <flex:remoting-destination ref="helloServiceDestination" /> 
    4. app-config.xml in spring 
    <bean id="helloServiceDestination" class="org.springframework.flex.samples.example.HelloWorld">   
      </bean> 
    5. HelloWorld.java 
    package org.springframework.flex.samples.example; 
      * TODO Document HelloWorld 
      * <p /> 
      * @author Vinod.Jayakumar 
    public class HelloWorld { 
    public String getHelloWorld(){ 
         return "HelloFromJava"; 
    expected result : http://localhost:1977/testdrive/FlexHelloWorld.html on click of button in the screen a alert message "HelloFromJava" should be shown but i get the following error message :  
    (mx.rpc::Fault)#0 
       content = (null) 
       errorID = 0 
       faultCode = "InvokeFailed" 
       faultDetail = "Couldn't establish a connection to 'helloServiceDestination'" 
       faultString = "[MessagingError message='Destination 'helloServiceDestination' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']" 
       message = "faultCode:InvokeFailed faultString:'[MessagingError message='Destination 'helloServiceDestination' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']' faultDetail:'Couldn't establish a connection to 'helloServiceDestination''" 
       name = "Error" 
       rootCause = (null) 
    Request you all to provide your valuable inputs. I know there's really something silly which has gone wrong

    Hi jvk180:
    Firstly, you should either need to define the destination in remoting-config.xml or in app-context.xml, but and in both places.
    Secondly, the error indicates that it is missing the channel information.
    Option 1:
    Assuming your bean "helloServiceDestination" uses other Spring beans, then:
    1. The right place to declare the destinations is in app-context.xml.
    2. In that case, you need to also define the channels that the destination will be exposed over. See documentation for how to do that.
    3. In your remote object declaration, you need to pass the channel set that gets used as well.
    <mx:ChannelSet id="cs">
       <mx:AMFChannel url="http://<yourServerName>:<yourServerPort>:/<yourContextRoot>/messagebroker/amf"/>
    </mx:ChannelSet>
    <mx:RemoteObject id="ro" destination="helloServiceDestination" channelset="{cs}" result="resultHandler(event)" fault="faultHandler(event)"/>
    Option 2:
    If you declare your destination, in remoting-config.xml, then you need to compile your swf with services-config.xml. Refer to documentation for how to do that.
    Hope that helps.
    Rohit

  • Flex - BlazeDS - Java: int are set to 0 when they should be kept to NULL.

    Hi everyone, I'm having an issue with Flex -> BlazeDS -> Java.
    When I pass an object to Java through BlazeDS, my variables of type int are automatically set to 0 if they are NULL or NAN. Is there a way to keep them as NULL ?
    Thanks everyone.

    Please refer to --
    https://bugs.adobe.com/jira/browse/BLZ-305

  • Poker game experiencing lag problems

    I've recently written a semi-functional Poker game however I'm experiencing problems with the game slowing down drastically as game play continues. I only have some basic high school programming knowledge so please forgive me for my extremely poor coding practice. Included are are the source files and jar. Any help would be appreciated. Thanks

    Ducky24 wrote:
    Upon using the Net Beans profiler I am finding myself quite shocked. The results show that invoke my formatJButton some 181000 times however I have no idea why it is invoked such.You have your swingComponent() method being called from inside of your paintComponent() method, and that seems like a bad idea to me. Every time your screen redraws, it will call this method, and it seems to me that it should be the other way around -- Your swingComponent should be involved with changing things and then call revalidate() and repaint() to relayout and redraw things.
    Again, I can't force myself to look at all of your code, but I wonder if you should be using a CardLayout here to swap JPanels rather than removing and repositioning and such.

  • Poker game logic

    has anybody ever tried to make a poker game
    if you have, please help me.
    if you have not, please help me if you can.
    how would you check weather there is a winning hand.
    the possibilities are Royal Flush, Straight Flush, 4 of a kind, full house, flush, straight, 3 of a kind, 2 pair, pair.
    pseudocode would be very nice.
    also, if you know a website where i could find some examples, that would also be very nice.
    Thanks.

    Although I dislike using ints for enums, I might do it here on the groups that maps from Object to int aren't readily available, and constantly boxing and unboxing is nice. Anyway...
    Each Card should have a getSuit() method and a getValue() method. Have two arrays, int[] suitCount = new int[4], and int[] valueCount = new int[13]. Go through the five cards incrementing the various indices. Then e.g. you have a flush if one of the suitCount elements is 5; a full house if one of the valueCount elements is 3 and one is 2, etc. Straights are slightly more work - you could check them by initialising an int straightCount = 0 and then for i = 0 to 13 (because A counts high and low) if valueCount[i % 13] == 1 then {straightCount++; if straightCount == 5 you have a straight} else straightCount = 0.

  • Poker game logic(again)

    i think that this will be the last thread that i will start on the subject of poker.
    if you have not looked at the other poker game logic threads, it might help.
    if figured out ways to check for repeaded cards(2,3,4,2&2,2&3) and how to do the flush. I am only having trouble figuring out if ther is one of the straights(cards in ascending order).
    you can check the suit and the rank of each card and there are 5. how do you figure if they are in a particular order?
    THANX!

    Sort the card array by face value of card. then
    boolean straight()
    if( ((a[0]+1) == a[1]) && ((a[1]+1) == a[2]) && ... etc. )
    return true;
    You will have to account for ace-2-3-4-5 too though. or 10-j-q-k-ace depending on the value you assign an ace.

  • Connection SQLite with Flex Web Based App??

    Hi! I have a problem, I create a Flex Web Based App in Flash Builder 4 and I need connect that app with my SQLite database... but I can't found the method that permit me create that connection.
    My question is... exist some method or some kind of code with I can do the connection?
    Can someone help me, please?

    SQLLite is only available in AIR apps.
    The preferred method for a web-app is to use some kind service architecture to expose your data. I wouldn't be able to offer any specific advise without knowing more about your deployment environment.

  • Why can,t i load the poker game fantasy poker

    why cant i not load the fantasy poker game poker

    Hello,
    What type of computer and internet connection are you using?
    MrMatthew - HP Support Forums Moderator
    Click the Kudos star as a way to say "thank you" for helpful posts.
    Be sure to come back and click the 'Accept as Solution' button on the post that solved your issue - it may help someone else.

  • Optimal communication strategy for poker game

    Hi,
    I'm designing a client/server poker game, and I'm trying to decide on the best protocol for client/sever comms. It's a personal project, so it doesn't need to be 100% robust or extensible.
    I was thinking of the following model:
    Client(s) and server communicate via Object Input/Output Streams over a socket. Client opens a Listener thread which listens in a while(true) loop, and Server also listens in a while(true) and processes incoming messages. The communication workflow will follow a request-response model.
    I will create my own Message class(String sender, int msgType, Object msgValue), and both listening classes will use switch(msgType) statements to process requests.
    Does anybody have any recomendations/stipulations regarding this model? There are a couple of issues I can think of:
    1. Use of while(true) loops should be avoided
    2. What happens to forever-listening ObjectInputSrteams when the client disconnects unsafely?
    3. How should the server handle client disconnects? Is it sufficient to use the onWindowClose method in the client GUI?
    Any feedback appreciated, thanks in advance,
    Sean

    Why not use RMI instead of plain sockets? The server part can be a
    simple facade to the real poker server (which can be a simple POJO).
    The 'business logic' (the poker game itself) is handled by the real
    poker server while all communication stuff is handled by RMI. That way
    the clients don't have to be aware of the fact that they're talking to some
    thing remote and it frees you from implementing that communication
    layer with all its burden.
    kind regards,
    Jos

  • HT203433 I want to buy chips for a poker game and it keeps telling me to visit itunes/support

    I want to buy chips for a poker game and it keeps telling me to visit www.apple.com/support/support/itens/ww/. My credit card doesn't have a hold and it is a good credit card.  please someone help

    You need to contact itunes support.

  • Poker game help needed!

    I am a beginning Java programmer. I am trying to teach myself and found an example of code for a Java poker program when I was looking online for things to do. It uses classes/methods (which I am still learning), and consists of: Card, Deck, and Hand (and PokerHand). Help with any of the sections would be excellent!
    * Card
    * Member Variables:
    *   INSERT DESCRIPTION OF MEMBER VARIABLES
    * Private Methods:
    *   INSERT DESCRIPTION OF PRIVATE METHODS (IF ANY)
    * Public Methods:
    *   INSERT DESCRIPTION OF PUBLIC METHODS (IF ANY)
    public class Card
        // constants representing the suits
        public static final int HEARTS = 0;
        public static final int CLUBS = 1;
        public static final int DIAMONDS = 2;
        public static final int SPADES = 3;
        // constants representing the named faces
        public static final int JACK = 11;
        public static final int QUEEN = 12;
        public static final int KING = 13;
        public static final int ACE = 14;
          public static final int CARD_PER_SUIT = 13;
        // member variabes
        // INSERT MEMBER VARIABLES HERE
         * Card Constructor
         * Takes as parameters the face and suit of the card
        public Card(int face, int suit)
            // INSERT CODE HERE
         * Card Constructor
         * Takes as parameter the card number
        public Card (int cardno)
         // INSERT CODE HERE
         * toString
         * Returns a String representation of the card
        public String toString()
            // return a String that contains a text representation of the card
                // INSERT CODE HERE
         * getFace
         * Returns the card's face value
        public int getFace()
            // return the face
            // INSERT CODE HERE
         * getSuit
         * Returns the card's suit value
        public int getSuit()
            // return the suit
            // INSERT CODE HERE
         * getCardNo
         * Returns the card number
          public int getCardNo()
                 // return the card number
               // INSERT CODE HERE
    } // end of class Card
    * Hand
    * Member Variables:
    *   INSERT DESCRIPTION OF MEMBER VARIABLES
    * Private Methods:
    *   INSERT DESCRIPTION OF PRIVATE METHODS (IF ANY)
    * Public Methods:
    *   INSERT DESCRIPTION OF PUBLIC METHODS (IF ANY)
    public class Hand
         public static final int HANDSIZE = 5;
         public static final int HIGH_CARD = 0;
         public static final int ONE_PAIR = 1;
         public static final int TWO_PAIRS = 2;
         public static final int THREE_OF_A_KIND = 3;
         public static final int STRAIGHT = 4;
         public static final int FLUSH = 5;
         public static final int FULL_HOUSE = 6;
         public static final int FOUR_OF_A_KIND = 7;
         public static final int STRAIGHT_FLUSH = 8;
         // member variables
         // INSERT MEMBER VARIABLES HERE
         // Hand Constructor
         // INSERT DESCRIPTION OF CONSTRUCTOR HERE
         public Hand()
              // instantiate a hand of cards
              // INSERT CODE HERE
         // resets a hand and throws away all cards in the hand
         // INSERT DESCRIPTION OF METHOD HERE
         public void resetHand()
              // INSERT CODE HERE
         // accepts a card to the hand
         // INSERT DESCRIPTION OF METHOD HERE
         public void TakeCard(Card card)
              // INSERT CODE HERE
         // How many cards does the hand have?
         // INSERT DESCRIPTION OF METHOD HERE
         public int getNumCards()
              // INSERT CODE HERE
         // return the card number of a card in a hand at a specified position
         // INSERT DESCRIPTION OF METHOD HERE
         public int getCard(int cardPosition)
              // INSERT CODE HERE
         // is this hand sorted?
         // INSERT DESCRIPTION OF METHOD HERE
         public boolean isSorted()
              // INSERT CODE HERE
         // sort the cards in this hand from low to high
         // INSERT DESCRIPTION OF METHOD HERE
         public void SortHand()
              // INSERT CODE HERE
         // returns a String that represents the hand
         // INSERT DESCRIPTION OF METHOD HERE
         public String toString()
              // INSERT CODE HERE
    * Deck
    * Member Variables:
    *   INSERT DESCRIPTION OF MEMBER VARIABLES
    * Private Methods:
    *   INSERT DESCRIPTION OF PRIVATE METHODS (IF ANY)
    * Public Methods:
    *   INSERT DESCRIPTION OF PUBLIC METHODS (IF ANY)
    public class Deck
         public static final int DECKSIZE = 52;
         public static final int SHUFFLE_TIMES = 1000000;
         // member variables
         /* INSERT MEMBER VARIABLES HERE */
         * Deck Constructor
         * INSERT DESCRIPTION OF CONSTRUCTOR HERE
         public Deck()
              // instantiate the deck of cards
                 /* INSERT CODE HERE */
         // shuffle the deck
         // INSERT DESCRIPTION OF METHOD HERE
         public void Shuffle(int n)
              /* INSERT CODE HERE */
         // deal a card from the deck
         // INSERT DESCRIPTION OF METHOD HERE
         Card Deal()
              // INSERT CODE HERE
         // how many cards are left in the deck?
         // INSERT DESCRIPTION OF METHOD HERE
         public int cardsLeft()
              // INSERT CODE HERE
         // INSERT DESCRIPTION OF METHOD HERE
         public String toString()
              // INSERT CODE HERE
         // INSERT DESCRIPTION OF METHOD HERE
         public void swap(int i, int j)
              // INSERT CODE HERE
    public class PokerHand
         public static void main (String[] args)
              Deck deck = new Deck();
              Hand hand;
              int i;
              String str;
              hand = new Hand();
              for (i = 0; i < Hand.HANDSIZE; i++) {
                   hand.TakeCard(deck.Deal());
              System.out.println("Player's hand (unsorted): ");
              System.out.println(hand.toString());
              hand.SortHand();
              System.out.println("Player's hand (sorted): ");
              System.out.println(hand.toString());
    }From what I can tell in the directions provided, what it has to do is display a list of the cards, both sorted and unsorted (in order of face value). I think it will be interesting (to my limited exposure), so, as said, any help with any of the classes would be appreciated. Thank you!

    Here's some old code - a game of Pontoon (aka BlackJack, 21 etc)
    a similar structure to your poker game, you'll just have to modify the hand values
    for pairs/straights etc, sorting and a few other things, but it should show you the
    relationship between the objects
    import java.util.*;
    import java.io.*;
    class Pontoon
      BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
      Deck deck = new Deck();
      public Pontoon()
        try
          String playAgain = "y";
          while(playAgain.equalsIgnoreCase("y"))
            playGame();
            System.out.print("\nAnother game? (y/n): ");
            playAgain = input.readLine();
        catch(Exception e){System.out.println("error - terminating");}
        System.exit(0);
      public void playGame() throws IOException
        Hand player = new Hand();
        Hand bank = new Hand();
        String anotherCard = "y";
        player.add(deck.drawCard());
        bank.add(deck.drawCard());
        player.add(deck.drawCard());
        bank.add(deck.drawCard());
        do
          for(int x = 0; x < 20; x++) System.out.println();
          if(player.getHandValue() > 21)
            for(int x = 0; x < 20; x++) System.out.println();
            bank.showHand(0,1);
            player.showHand(0,0);
            System.out.println("\nBank wins - player busted.\n");
            break;
          else
            for(int x = 0; x < 20; x++) System.out.println();
            bank.showHand(1,1);
            player.showHand(0,0);
            System.out.print("Draw another card? (y/n): ");
            anotherCard = input.readLine();
            if(anotherCard.equalsIgnoreCase("y"))
              player.add(deck.drawCard());
            else
              for(int x = 0; x < 20; x++) System.out.println();
              bank.showHand(0,1);
              while(bank.getHandValue() < 16)
                System.out.print("\npress [ENTER] to draw another card for bank.");
                String junk = input.readLine();
                bank.add(deck.drawCard());
                for(int x = 0; x < 20; x++) System.out.println();
                bank.showHand(0,1);
              if(bank.getHandValue() > 21)
                System.out.println("\nPlayer wins - bank busted.\n");
              else
                if(player.getHandValue() > bank.getHandValue())
                  System.out.println("\nPlayer wins - " + player.getHandValue() +
                                           " to " + bank.getHandValue() + ".\n");
                else if(player.getHandValue() < bank.getHandValue())
                  System.out.println("\nBank wins - " + bank.getHandValue() +
                                           " to " + player.getHandValue() + ".\n");
                else
                  System.out.println("\nDraw - " + player.getHandValue() +
                                           " to " + bank.getHandValue() + ".\n");
        }while(anotherCard.equalsIgnoreCase("y"));
        player = null;
        bank = null;
      public static void main(String[] args){new Pontoon();}
    class Hand
      java.util.List hand = new java.util.ArrayList();
      public Hand()
      public void add(Card card)
        hand.add(card);
      public int getHandValue()
        int handValue = 0;
        for(int x = 0; x < hand.size(); x++)
          handValue += ((Card)hand.get(x)).getValue();
        return handValue;
      public void showHand(int numberOfCards, int playerOrBanker)
        String whoseHand = playerOrBanker == 0? "Player":"Bank";
        System.out.println(whoseHand + "'s hand:");
        if(numberOfCards == 1)
          System.out.println(((Card)hand.get(0)).getName() + "\n");
        else
          for(int x = 0; x < hand.size(); x++)
            System.out.println(((Card)hand.get(x)).getName());
          System.out.println("\nHand total = " + getHandValue() + "\n");
    class Deck
      String[] faces = {"Ace","Two","Three","Four","Five","Six","Seven",
                             "Eight","Nine","Ten","Jack","Queen","King"};
      String[] suits = {"Hearts","Diamonds","Clubs","Spades"};
      final int DECKSIZE = 52;
      int cardsDealt;
      Card[] cards = new Card[DECKSIZE];
      java.util.List random = new java.util.ArrayList();
      public Deck()
        int value;
        for(int x = 0; x < cards.length; x++)
          value = (x % faces.length) + 1;
          if(value > 10) value = 10;
          else if(value == 1) value = 11;
          cards[x] = new Card(faces[x % faces.length],suits[x / faces.length],value);
          random.add(new Integer(x));
        shuffleDeck();
      private void shuffleDeck()
        java.util.Collections.shuffle(random);
        cardsDealt = 0;
      public Card drawCard()
        if(cardsDealt > 40) shuffleDeck();
        Card cardDrawn = cards[((Integer)random.get(cardsDealt)).intValue()];
        cardsDealt++;
        return cardDrawn;
    class Card
      private String name;
      private int value;
      public Card(String pFace, String pSuit, int pValue)
        name = pFace + " of " + pSuit;
        value = pValue;
      public String getName() {return name;}
      public int getValue() {return value;}
    }

Maybe you are looking for

  • Importing CD to desktop via iTunes for mp3?

    Is there a simple way to import CD's on a Mac to say a desktop folder, that converts them all to 192K mp3? I'm assuming this would involve doing this through iTunes? Or is there a simple way on OS X to import direct to mp3 to a folder? Thanks

  • Blank pages on the Adminui

    I have installed server Jboss.  I am able to log in. I can see the Home, Services, Settings options.  But when I click on user management, the pages are blank! Suggestions? Thank you in advance p.s. it is an Eval copy of ES4 Server

  • Change step type

    I recently inherited a TestStand project that needs changing. My main question is how to change a step type. For instance, sequence 1    step 1 (p/f) that programs 1 field in a device,    step 2 (p/f) that verifies field 1 in the device. sequence 2  

  • ReturnType="user-defined" returns wddx instead of SOAP

    No matter what I try, CF never returns a valid SOAP response when I try to use a CFC as a return type. When I call the cartShow method remotely, I get back wddx. cart2.cfc?method=cartShow&cookie_id=73BF9A83-CC22-47E7-8D25EA72746CDF32

  • Is KODO Standard edition "enough" for low db usage app?

    Hi, We have a Swing application used by 80 users. Our needs from JDO are: - Obj to table mapping (simple) - Relationship management (FK translated to obj. references) - Being able to generate JavaBeans out of db tables Can we use standard edition of