Taking strict turns in a cards game

I am implementing a cards game on the web and the clients are threads . how do I make them alternate strictly in turns on the server. Is there any way I can identify which thread it is and block its information.

You can identify which thread is running with static method Thread.getCurrentThread() (or it can call the synchronized method with some arguments identifying it). It is easy then to have it wait if it is not ist turn. The server is passive, it has no specific thread. It knows of all players thread and of their ordering. Player threads will run its play method. In this method, they will wait until their turn has come.
Here are too little classes that will sketch the system:
import java.util.Date;
public class GameServer extends Thread {
  private final Thread[] players;
  int currentPlayerIndex = 0;
  public GameServer() {
    players = new Thread[4];
    for (int p = 0; p < players.length; p++){
      players[p] = new PlayerThread(this, "Player " + (p+1));
      players[p].start();
  public synchronized void play(String playerName, long thinkTime){
    try{
      long waitStart = new Date().getTime();
      while(Thread.currentThread() != players[currentPlayerIndex])
        wait();
      long waitTime = new Date().getTime() - waitStart;
      System.out.println(playerName + " is playing. "
          + " Took " + thinkTime + " ms to think"
          + " Had then to wait for " + waitTime + " ms.");
      currentPlayerIndex = (currentPlayerIndex + 1) % players.length;
      notifyAll();
    } catch (InterruptedException e){
      e.printStackTrace();
  public static void main(String[] args){
    GameServer server = new GameServer();
}Here is player thread
public class PlayerThread extends Thread {
  private final GameServer server;
  public PlayerThread(GameServer aServer, String name) {
    super(name);
    server = aServer;
  public void run(){
    try {
      while(true){
        long thinkTime = Math.round(3000 * Math.random());
        Thread.sleep(thinkTime); // think
        server.play(getName(), thinkTime);
    } catch (InterruptedException e){
  }Two points:
1) This has to be improved to resist one player thread going down. Otherwise, when its turn comes, over will wait forever. You might need to be more careful with InterruptedException, and to set up a ThreadGroup for players so that you be notified with uncaughtException.
2) If players work the way I wrote them, you cannot do your scheduling with priorities. If a thread is sleeping (or waiting for some resource, or user input), giving it a high priority will not make its wait shorter. Another thread which happens to get its resource or input quicker will run first.. Better use priorities only as hints for optimization rather than for strongly constrained synchronization.

Similar Messages

  • Need some OO design pointers for a Java card game I wrote for uni

    Hi,
    I hope a few of you Java sifus can help me understand I dilemma I keep finding myself in.
    I created a card game for a university assignment which works great but its not very OO at the moment.
    I only have 3 classes; a Card class, a Deck class and a Game class which contains all my GUI, AI, Game Controller, Player and Hand code.
    The assignment is over but I feel like enhancing the game, adding animation, multiplayer, several AI agents etc.
    The first thing I have attempted is animation and I've hit a brick wall. I am trying to create animation for my card game whereby I have an animation showing the cards being shuffled and then an animation which shows the cards being dealt to the players. The game then commences. The cards on the GUI then need to be clickable (MouseListeners?) to play the game. If you're running Windows 7, load up 'Hearts' and you'll know what I'm trying to achieve.
    I don't understand how the GUI, and Card class need to be seperated so that its good OO.
    If I give you a few snippets of code, it might explain the situation:
    A snippet of my card class is as follows:
    import javax.swing.*;
    public class Card extends JLabel //Each card is a JLabel
         private int value;                    //variable for the value of the card
         private int suit;                         //variable for the suit of the card
         private ImageIcon frontOfCard;     //Displays the image of the front of the cards
         private ImageIcon backOfCard;          //displays the image of the back of the cards
         public Card (int Value, int Suit, ImageIcon front, ImageIcon back)
              value = Value;               
              suit = Suit;               
              frontOfCard = front;     
              backOfCard = back;
              setIcon(backOfCard);     //To make it non-visible when dealt
         }As you can see, each card is a JPanel. I've been told by some I shouldn't extend JPanel but rather that I should have a BufferedImage/Image instance variable for each card as the image of the card. The thing is that I need each card displayed on the GUI which can then be clickable. When it is clicked, it is moved from the players hand, into the players move. - There needs to be an animation showing this.
    I've got the animation code figured out in terms of how to move 'images' around a screen to make a pleasing animation. The problem is there are no clickable listeners for images, so the Images needs to be inside some container; a widget which can fire events - Hence the reason I have chosen to extend JPanel for my Cards.
    and a Deck class, snippet is as follows:
    public class Deck extends JLabel //The deck will be shown on the GUI as a JLabel
         private ArrayList<Card> standardDeck;
         public Deck()
              standardDeck = new ArrayList<Card>();
              ImageIcon cardBack = new ImageIcon("CardBack.png");
              setPreferredSize(new Dimension(90, 135));
              setIcon(cardBack);
              int cardCount = 0;     //This variable counts the cards. Is used to assist in the name generation of the imageicon filename
              String str; //the imageIcon constructor accepts filenames as strings so this string holds the filename of the corresponding card image file.
              for (int a=0; a<4; a++) //putting the cards into the deck with the specifed parameters
                   for (int b=2; b<15; b++)
                        cardCount+=1;     //incrementing the card count (the card files are named 1-52 as integers)
                        str = Integer.toString(cardCount); //Integer is converted to string type before being added to string str variable
                        str += ".png"; //To complete the image filename, ".png" has to be concatenated to the string.
                        standardDeck.add(new Card(b, a, new ImageIcon(str), cardBack)); //creating and then adding the cards
         }This is how I envisage a new class diagram for my game:
    Card class
    Game Class <--- Holds a Deck instance, Players instances, and the GUI instance
    Player Class <-- Will contains hand 'instances' , but I will not create a seperate 'Hand' Class, I will use an ArrayList.
    AI Class extends Player Class
    GUI Class
    Deck Class <-- contains 52 cards
    My question is, how do I show the Cards on the GUI if my Cards are in a Deck and the Deck is held in the Game class?
    Please note that there are 52 cards, so potentially 52 images on the GUI, each of which needs to be clickable. When clicked, the cards are moved about, e.g. from the deck to a players hand, from a players hand back to the deck, from a players hand to a players current move hand.
    etc
    I've read that GUI, program control, and logic should be seperated. If thats the case, what do I have in my GUI class if the Cards (which are JPanels) are held in the Deck class which in turn is held in the Game class?
    Any help on this would be greatly appreciated!
    I know what I have written may not be fully clear. I find it hard sometimes to fully convey a problem at hand. Please let me know if you don't understand what I've written and I'll do my best to explain further.

    Faz_86 wrote:
    Hi,
    I hope a few of you Java sifus can help me understand I dilemma I keep finding myself in.
    I created a card game for a university assignment which works great but its not very OO at the moment.
    I only have 3 classes; a Card class, a Deck class and a Game class which contains all my GUI, AI, Game Controller, Player and Hand code.
    The assignment is over but I feel like enhancing the game, adding animation, multiplayer, several AI agents etc.
    Admirable, and the best way to learn, doing something that interests you.
    The first thing I have attempted is animation and I've hit a brick wall. I am trying to create animation for my card game whereby I have an animation showing the cards being shuffled and then an animation which shows the cards being dealt to the players. The game then commences. The cards on the GUI then need to be clickable (MouseListeners?) to play the game. If you're running Windows 7, load up 'Hearts' and you'll know what I'm trying to achieve.
    I don't understand how the GUI, and Card class need to be seperated so that its good OO.
    If I give you a few snippets of code, it might explain the situation:
    A snippet of my card class is as follows:
    Do a quick Google on the model view controller pattern. Your listeners are your controllers. Your JPanel, JButton, etc. are your view. The AI, Player, Card and Deck (and presumably something like Score) are your model. Your model should be completely testable and not dependent on either the controller or the view. Imagine you could play the game from the command line. Get that working first. Then you can add all the bells and whistles for the UI.
    import javax.swing.*;
    public class Card extends JLabel //Each card is a JLabel
    (redacted)
    As you can see, each card is a JPanel. I've been told by some I shouldn't extend JPanel but rather that I should have a BufferedImage/Image instance variable for each card as the image of the card. The thing is that I need each card displayed on the GUI which can then be clickable. When it is clicked, it is moved from the players hand, into the players move. - There needs to be an animation showing this.Extending JPanel is fine. As you noted, you need something to add listeners to. However, I would separate things a bit. First, a card really only has a rank and suit (and perhaps an association to either the deck or a player holding the card). The notion of setIcon() is where you are tripping up. The card itself exists in memory. You should be able to test a card without using a UI. Create a separate class (CardPanel or something similar) that has a reference to a Card and the additional methods needed for your UI.
    I've got the animation code figured out in terms of how to move 'images' around a screen to make a pleasing animation. The problem is there are no clickable listeners for images, so the Images needs to be inside some container; a widget which can fire events - Hence the reason I have chosen to extend JPanel for my Cards.
    and a Deck class, snippet is as follows:
    public class Deck extends JLabel //The deck will be shown on the GUI as a JLabel
         private ArrayList<Card> standardDeck;
         public Deck()
              standardDeck = new ArrayList<Card>();
              ImageIcon cardBack = new ImageIcon("CardBack.png");
              setPreferredSize(new Dimension(90, 135));
              setIcon(cardBack);
              int cardCount = 0;     //This variable counts the cards. Is used to assist in the name generation of the imageicon filename
              String str; //the imageIcon constructor accepts filenames as strings so this string holds the filename of the corresponding card image file.
              for (int a=0; a<4; a++) //putting the cards into the deck with the specifed parameters
                   for (int b=2; b<15; b++)
                        cardCount+=1;     //incrementing the card count (the card files are named 1-52 as integers)
                        str = Integer.toString(cardCount); //Integer is converted to string type before being added to string str variable
                        str += ".png"; //To complete the image filename, ".png" has to be concatenated to the string.
                        standardDeck.add(new Card(b, a, new ImageIcon(str), cardBack)); //creating and then adding the cards
         }This is how I envisage a new class diagram for my game:
    I am not an animation buff, so I will assume the above works.
    Card classRemove the UI aspects to this class, and I think you are all set here.
    Game Class <--- Holds a Deck instance, Players instances, and the GUI instancePresumably this is where main() resides. It will certainly have a reference to model classes (player, game, deck, etc.) and likely the master JFrame (or a controller class you create yourself).
    Player Class <-- Will contains hand 'instances' , but I will not create a seperate 'Hand' Class, I will use an ArrayList.Does a player really have multiple hands? It seems to me more of a one-to-one relationship (or a player has a one-to-many relationship to Card).
    AI Class extends Player ClassWhy extend Player? Create a Player interface, then have a HumanPlayer and AIPlayer implementation. Common parts could be refactored out into either a helper class (delegation) or AbstractPlayer (inheritance).
    GUI ClassMy assumption is that this class has a reference to the master JFrame.
    Deck Class <-- contains 52 cards
    Yes. You may end up recycling this class such that a Deck can also function as a Hand for a given player. If there are differences between the two, create an interface and have a Hand and a Deck implementation. Coding to interfaces is a good thing.
    My question is, how do I show the Cards on the GUI if my Cards are in a Deck and the Deck is held in the Game class?You need to pass a reference to the appropriate view class. That is how MVC works. The controller receives a request from the view, dispatches to some model functionality you write (such as GameRulesEngine, Deck, etc.) and returns a result to the view (which could be the same view or a different one, imagine someone clicking 'high scores').
    Please note that there are 52 cards, so potentially 52 images on the GUI, each of which needs to be clickable. When clicked, the cards are moved about, e.g. from the deck to a players hand, from a players hand back to the deck, from a players hand to a players current move hand.
    etc
    That is up to you to write the animation code. In principle, you have a mouse listener, and then you take the appropriate rendering steps.
    I've read that GUI, program control, and logic should be seperated. If thats the case, what do I have in my GUI class if the Cards (which are JPanels) are held in the Deck class which in turn is held in the Game class?
    See above.
    Any help on this would be greatly appreciated!
    You are welcome.
    I know what I have written may not be fully clear. I find it hard sometimes to fully convey a problem at hand. Please let me know if you don't understand what I've written and I'll do my best to explain further.No, you have been doing fine.
    - Saish

  • S890 screen turns off while playing games

    I bought this phone a week ago.Everything about this phone is awesom except one thing. The screen turns off while playing games automatically,which is really annoying. Is there any fix for this??

    Graphics card springs to mind;
    also, in your game settings, in either options or video settings (or similar). Are the settings correct for your card. I know on a low end PC, "full hardware acceleration" can cause crashing.
    I'd still think, it's more a graphics related problem. If you have a big flat screen mintor (e.g 24,27 or even 30") then that, in it's own right needs a good card. Add the game to it and you may have problems. I do take it you have compared the specs with what's required on the box (of the game) and "about this mac/"more info"). All the best.

  • Card Game related question

    Hello, I am not sure what forum this goes to or if it goes under any forum, but I was wonder if anyone has a way of taking an array of 7 cards placing an array of 5 cards made from the seven in a hashtable so that it will drop ever possible combination of those cards.
    Or if you have a better way of doing that
    If you are wonder I am making a Texas Holdem style poker game...
    Thank you for any and all help :)

    Start here:
    http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html
    Good beginner card game examples there.
    As far as every possible combination, you will probably need a recursive combinations method of some sort.

  • Creating cards for a card game

    So I'm playing with the idea of putting together a simple battle card playing game and am running up against a data/code issue. In the game will be various Cards (potentially hundreds). Each card will have some data describing various its strengths and it may also have complex methods that handle what happens when you play the card.
    (I'd like each Card implementation to represent what the card does, as opposed to who may hold a particular copy of it. For example, I'd like to have a unique JackOfDiamondsCard object that represents info specific to the card. I may then have several Hands that contain CardInstance objects, some of which may have a reference to the unique JackOfDiamondsCard object. Thus the JackOfDiamonsCard could appear in multiple hands.)
    At first glance it's a simple case of having a root Card class and hundreds of children that fill out the details. However, this has the problem that I can create many instances of the same card, which both seems like a waste of memory (since all instances would have exactly the same data) and would make equals() and hashCode() give different results for different instances of the same card.
    One way around this is to put all the cards together into a single enum, but that would quickly grow to an unmanagable (and unreadable) size. I'd also like to be able to group the cards into different packages, or maybe even spread them across several jars.
    Another way may be to turn each card into a singleton and then build an index of all the cards in the jar (maybe using @annotations?) This seems kind of complicated, though, and writing all those singletons would make for a lot of boilerplate in each card class.
    Any ideas on a good way to tackle this? Are singletons the way to go or should I put up with potentially multiple copies of the same card object floating around?

    Mark_McKay wrote:
    The problem is that I need the overriding classes to provide some fairly complex code for each card. In a battle card game, there may be several different things in play that each card could alter in a wacky way. One card may give the player more 'energy points'. Another may strike the opponent with lightning damage. A third may cause one player to randomly steal a card from the other player. A fourth could set up some sort of defense barrier. The wide (and unpredictable) range things that each card may do prevent me from creating just one generic card class. (Although that would work well if the cards only differed by their data).Allow me to introduce some friends of mine. Probably the first one is going to be easiest for you to understand and get working quickly. The last one, probably only any use in conjunction with one of the others here.
    This wacky behaviour is really just another property of the card, like it's suit, or name, or whatever. Behaviours, like data, can often be assigned to objects at runtime, rather than expressed with unweildy inheritance trees.

  • Card Game Output Error Message

    Hi, everyone,
    I'm making a card game with two shuffling decks. The cards from both decks are also supposed to flip and drag. My first deck is working fine, but in my second deck, the card won't flip. Every time I try to flip the card in the second deck, I get this output message:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Wicky/clickCard()
    I don't get any compiler errors at the moment, but I get that message every time I click on deck two. The card does drag, but it won't flip, and that error message pops up. Does anyone have an idea of where my mistake might be?
    I have two files, Wicky.as and Wicky.fla. Below is the code for Wicky.as. Thanks in advance for your help!
    Wicky.as
    package {
    import flash.display.*;
    import flash.events.*;
    public class Wicky extends MovieClip {
      // game constants
      private static const boardWidth:uint = 7;
      private static const boardHeight:uint = 7;
      private static const boardOffsetX:Number = 120;
      private static const boardOffsetY:Number = 45;
      private var firstCard:Card;
      private var secondCard:Card;
      private var thirdCard:Card2;
      private var fourthCard:Card2;
      public function Wicky():void {
       // make a list of card numbers
       var cardlist:Array = new Array();
       for(var i:uint=0;i<boardWidth*boardHeight;i++) {
        cardlist.push(i);
       var cardlist1:Array = new Array();
       for(var j:uint=0;i<boardWidth*boardHeight;j++) {
        cardlist.push(j);
       // create all the cards, position them, and assign a randomcard face to each
       for(var x:uint=0;x<boardWidth;x++) { // horizontal
        for(var y:uint=0;y<boardHeight;y++) { // vertical
         var c:Card = new Card(); // copy the movie clip
         c.stop(); // stop on first frame
         var r:uint = Math.floor(Math.random()*cardlist.length); // get a random face
         c.cardface = cardlist[r]; // assign face to card
         cardlist.splice(r,1); // remove face from list
         c.addEventListener(MouseEvent.CLICK,clickCard); // have it listen for clicks
         addChild(c); // show the card
         // create all the cards, position them, and assign a randomcard face to each
         var b:Card2 = new Card2(); // copy the movie clip
         b.stop(); // stop on first frame
         var s:uint = Math.floor(Math.random()*cardlist1.length); // get a random face
         b.cardface = cardlist1[s]; // assign face to card
         cardlist1.splice(s,1); // remove face from list
         b.addEventListener(MouseEvent.CLICK,clickCard); // have it listen for clicks
         b.x = 200
         b.y = 200
         addChild(b); // show the card
       // This function is called when the mouse button is pressed.
       function startDragging(event:MouseEvent):void
            event.currentTarget.startDrag();
        // This function is called when the mouse button is released.
        function stopDragging(event:MouseEvent):void
           event.currentTarget.stopDrag();
       c.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
       c.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
       b.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
       b.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
      // player clicked on a card
      public function clickCard(event:MouseEvent) {
       var thisCard:Card = (event.target as Card); // what card?
        firstCard = thisCard; // note i
        firstCard.gotoAndStop(thisCard.cardface+2); // turn it over
       public function clickCard1(event:MouseEvent) {
       var thatCard:Card2 = (event.target as Card2); // what card?
        thirdCard = thatCard; // note i
        thirdCard.gotoAndStop(thatCard.cardface+2); // turn it over

    Hey, Ned,
    Yeah, I can imagine that would be frustrating.
    I guess the moral of that story is, when somebody says something is impossible, get a second opinion, right? :  )
    Have a good weekend,
    Peter

  • HT201272 i paid and downloaded Card Game ( UNO) is does not work

    Uno card game off apps store does not work on my i-pad 4th generation

    Have you tried deleting the apps and re-downloading it ? If that doesn't fix it then you could try contacting the app's developer (there should be a link on its description page in the store).
    If you don't get a reply from the developer then try the 'report a problem' link from your purchase history : log into your account on your computer's iTunes via Store > View My Account (Store > View My Apple ID on iTunes 11) and you should then see a Purchase History section with a 'see all' link to the right of it ; click on that and you should see a list of your purchases ; find that app and use the 'Report a Problem' link and fill in details about the problem (iTunes support should reply within, I think, about 24 hours).
    Some people have had a problem with the 'report a problem' link (it's been taking people to this site on a browser instead of showing a form in iTunes) - if it does that to you then try contacting iTunes support via this page : http://www.apple.com/support/itunes/contact/- click on Contact iTunes Store Support on the right-hand side of the page.

  • Want to host Flash-based card games on CF site

    Hi - does anyone know of a service or producer that would allow me to host card games on my CF site? Or, are there any flash modules around that I can customize for my own database?
    Any suggestions would be appreciated! Karen

    post54,
    > I sent an e-mail with links to the census page on
    adobe.com
    > that states that flash is installed on 97% of internet
    enabled
    > computers. They don't believe it.
    The numbers on Adobe's stats page don't always refer to the
    *latest*
    version of Flash Player -- that's an important note -- but
    certainly, the
    numbers are good:
    http://www.adobe.com/products/player_census/flashplayer/version_penetration.html
    Here's the methodology used to derive those numbers:
    http://www.adobe.com/products/player_census/methodology/
    Are the naysayers on your end willing to cite a reference or
    two? ;)
    > In fact, one of my superiors believes that number to be
    only 9%.
    Ummm. Where is that number coming from? Has this person not
    visited
    Amazon.com? They use Flash content. That's a pretty major
    e-commerice
    site. His this person not heard of MySpace (et. al.), YouTube
    (et. al.),
    and the like, all of which support (and sport) Flash content?
    How about
    cnn.com? Check out any of the major TV outlets, abc.com,
    fox.com, cbs.com,
    etc. I'm preaching to the choir, though ... I realize that.
    > I've tried to do some of my own research but I'm having
    a hard
    > time building a case. I desperately need independent
    research that
    > illustrates what I'm sure we all know already:
    This might prove difficult, because it sounds (to me) like
    you're up
    against an emotional reaction more than anything else. If no
    one jumps in
    with the article(s) you're looking for, how about turning the
    argument on
    its ear? You mentioned that the Flash content you're after is
    "nothing
    major" -- more eye candy than anything else -- and if that's
    so, why not use
    something like Geoff Stearns' SWFObject to detect Flash
    Player and serve up
    an alternative if necessary?
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Java Card Game (Carioca)

    Hi everyone.
    Im currently making a card game in java for a south american game called Carioca
    originally i had
    CariocaController, which controlled game logic such as creating cards and players, dealing the cards setting the cards etc.
    btnStartGame in GUI would run controller method startGame which would initialize everything then set the GUI.
    CariocaTablelGUI, which extended JFrame and set the game GUI by using swingcomponents (JButtons with ImageIcons for cards)
    Card, like it says, card suit, no and value
    Deck, which created an ArrayList<Card> + 2 jokers.
    Pile which extended ArrayList<Card>. (Used for creating the 2deck game, player hands, putdown pile)
    Ive never been to good with GUI's and not enjoying my inopropriate gui structure i decided to read about java game designs.
    I read OReilly Killer Game Programming in Java chapters 1-13 before it got into 3d java. and not feeling it provided the examples i needed i went back to my old book
    Deitel & Deitel How to program Java Fifth edition. which has a case study of ElevatorSimulation which uses the Model View Controller design pattern.
    I have used this simulation as my guide to reform my code structure as i want to create this game as proffesionally and efficiently as possible.
    Now i have.
    CariocaTable which extends JFrame and in its constructor;
              // instantiate model, view and ,controller
              model = new CariocaModel();
              view = new CariocaPanel();
              controller = new CariocaController(model);
              // register View for Model events
              model.setCariocaListener( view );
              add(view, BorderLayout.CENTER);
              add(controller, BorderLayout.SOUTH);CariocaPanel in it has 4 player panels (4 player max game) which would contain their hands. then a center panel which contains the pickup and putdown piles.
    I am having alot of trouble implementing this pattern to my game (mybe im on the wrong track).
    the controller (in the ElevatorSimulation ) has 2 buttons which executes model method addPerson, thats about all the controller does which rocks my understanding.
    the model implements ElevatorSimulationListener (which extends all needed listeners) and has private variabels for all listeners.
    it then has a setElevatorSimulationListener(ElevatorSimulationListener listener) which is set with the view class.
    i have trouble understanding the communication between controller-view and model-view.. controller has to go threw model to talk to view but model only talks to view through listener methods
    public void lightTurnedOff( LightEvent lightEvent )
    //variable lightListener is the view.
          lightListener.lightTurnedOff( lightEvent );
       }i dont know where all the logic should go. i currently have model with the startGame method which creates players and cards, deals cards etc.
    am i on the right track. am i misunderstanding the design pattern? im sorry for the lengthy post, im having trouble understanding this and would like assistance with my understanding or even refer me to a book or website the would be helpful. if u would like more information please do ask.

    morgalr wrote:
    OK, I'll make a few assumptions and you can correct me if I am wrong on any of them:
    1 - the game is for 1 person to play against the computer
    2 - you may want to expend to multiplayer at some point
    3 - you would like to have the structure of the game as modular as possible to allow changesThank you for replying, yes thats exactly right.
    My approach now is to maintain the same structure as before instead of using the ElevatorSimulation as a guide.
    CariocaController will contain game logic and the static main method, and will update CariocaTable threw set methods.
    i will keep the revamped GUI classes, using what ive learned about using 2d instead of Swing Components, ive created an ImageLoader class which CariocaTable instantiates that loads all images into a hash map. PlayerPanel for each player, each panel contains variable Player, Pile hand, Pile downHand (objective of the game). Mybe i should get rid of the pile variables since the class Player already contains them?
    Its the drawing of the GUI that gets to me. Any other suggestions or ideas?

  • What are the Trading Card Games for iPod touch that doesn't requires Internet connection?

    What are the Trading Card Games for iPod touch that doesn't requires Internet connection? Suggestions, please.

    Why not look at the apps and fine out?
    The odds of someone here knowing that are slim to none.

  • HT201272 i have download 120 mb size (uno card game) on my laptop how can i get it on my iphone s4

    i have download 120 mb size (uno card game) on my laptop how can i get it on my iphone s4

    If you downloaded it from the app store on your computer's iTunes then connect your iPhone to your computer and select it on the left-hand side of your computer's iTunes, and then use the Apps tab on the right-hand side of iTunes to select and sync that app to the phone.
    If you downloaded it somewhere else then you won't be able to copy it to your phone - only iTunes apps work on iOS devices, PC and Mac software aren't compatible with them.

  • Can't load masque card games on my laptop

    why can't I load masque card game to my laptop. it said pro mac not supported

    This says the game supports Mac OS 8.1, so I suspect it's a Classic app, which would require a Classic environment, which hasn't been supported by Apple since OS 10.5 or on any Intel Macs.
    http://www.amazon.com/Masque-Card-Games-Mac/dp/B0000C0ZC0

  • Data Writing Speed for Excel Sheet while taking data from PCI DAQ card

    Dear All,
              I am taking the data form the card EX-92026 pci card and writing those datas into the Excel sheet, now i want the data at the speed of max of 10 miliseconds but while writing the data into excel sheet, it shows the diff of 15 ms betn 2 readings, and the card specs says it takes the time of 500 microsecs to give the data, so is there any effect of timing, while writing data into excel sheet? is labview take more time, i am using the Open file, write file and close file method and write to spreadsheet file method, but none of them is giving me the effective timing that i wamt, so can u tell me how can i reduce it??????
    Thanks,
    Nishant

    Hi Nishant:
    I think I don't understand you very well. If you are using OpenFile, CloseFile and WriteToSpreadsheet VIs, you are not dealing with excel files, but text files.
    Writing to file is costly in time. You can:
    Open the file just once and
    during de process use just file writing VIs as 'write to spreadsheet'... or a more simple one 'write file'
    Close the file once at the end.
    If you need the process to be faster, you can save all the data at 10ms rate in an array and write to file at the end.
    Or write to file every second what you got the last second.
    Hope it helps
    Aitortxo.
    Aitortxo.

  • Advice to implement a mouse listener for card game

    Hi,
    I am wondering about the best way to apply a mouselistener in my card game.
    - i only want to listen for 'clicks'
    - I have a JFrame with a JPanel inside. The JPanel has a null layout and many JLabels. The JLabels are the cards, i want to listen for mouse clicks on these 'cards'
    I have seen it is not possible to apply a mouse listener to a JPanel or JLabel so is the most efficient way to apply the listener to the JFrame and then use getComponent () to determine which JLabel has been clicked ? or is there a better way ?
    any thoughts appreciated . .

    hey dubai, thanks for your quick help today, it is much appreciated !
    i know the event should provide a reference to the source, i use the toString to overide the methods in the mouseEvent object and im printing this string to the console. It gives me the correct dimensions within my JPanel of where i clicked but the source is always given as the panel name. Have you any idea why it does not return the name of the JLabel ? I checked out the Action interface, thanks, it cud be very useful to seperate the code by using this.

  • Question - making rummy card game applet

    Hi, I am not sure if this is the right place to be putting this, if not please let me know. I'm trying to make an applet for the card game rummy for my final project for school. I was wondering if I could get some help on how to load a card image from a file and randomizing the images for the deal button or if not that then I am also trying a much simpler way due to time constraints. I was trying to make two arrays of strings: one for the facevalue of the card and another for the suit value, then randomize those and draw a string to the correct places for the dealt hand. I can't seem to get this to work well so far. Any help is greatly appreciated. Here is the code for the basic gui that I have now.
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.util.Random;
    import java.lang.*;
    public class CardGame extends Applet implements ActionListener {
         Button Deal;
         Button NewGame;
         Button PutDown;
         Color bgColor;
         Color rectColor;
         Image deck;
         MediaTracker mt;
         CheckboxGroup radioGroup;
         Checkbox radio1;
         Checkbox radio2;
         Checkbox radio3;
         Checkbox radio4;
         Checkbox radio5;
         Checkbox radio6;
         Checkbox radio7;
    **Its hard to tell but the arrays are commented out for now.     
         //String[] faceValue = {"ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING"};
    //     String[] suitValue = {"CLUBS", "HEARTS", "SPADES", "DIAMONDS"};
         public void init()
              setLayout(null);
              mt = new MediaTracker(this);
              Deal = new Button("Deal");
              NewGame = new Button("New Game");
              PutDown = new Button("Put Down");
              Deal.setBounds(750, 450, 75, 25);
              NewGame.setBounds(750, 475, 75, 25);
              PutDown.setBounds(750, 425, 75, 25);
              add(Deal);
              add(NewGame);
              add(PutDown);
              Deal.addActionListener(this);
              NewGame.addActionListener(this);
              PutDown.addActionListener(this);
              radioGroup = new CheckboxGroup();
              radio1 = new Checkbox(" ", radioGroup, false);
              radio2 = new Checkbox(" ", radioGroup, false);
              radio3 = new Checkbox(" ", radioGroup, false);
              radio4 = new Checkbox(" ", radioGroup, false);
              radio5 = new Checkbox(" ", radioGroup, false);
              radio6 = new Checkbox(" ", radioGroup, false);
              radio7 = new Checkbox(" ", radioGroup, false);
              add(radio1);
              add(radio2);
              add(radio3);
              add(radio4);
              add(radio5);
              add(radio6);
              add(radio7);
              radio1.setBounds(143, 525, 10, 10);
              radio2.setBounds(222, 525, 10, 10);
              radio3.setBounds(301, 525, 10, 10);
              radio4.setBounds(380, 525, 10, 10);
              radio5.setBounds(459, 525, 10, 10);
              radio6.setBounds(538, 525, 10, 10);
              radio7.setBounds(617, 525, 10, 10);
         public void Randomize()
              //this is where I need the help mostly.
         public void Stop()
         public void actionPerformed(ActionEvent evt)
         if (evt.getSource()== Deal)
                   setBackground(Color.green); //test
              else
                   Deal.setLabel("Not there, here!"); //another test
         if(radio1.getState())
                   setBackground(Color.blue); //just a test to make sure I know how to use the radio buttons
         public void paint(Graphics g) {
              g.drawString("Welcome to Rummy!!", 300, 50 );
              g.drawRect(100, 100, 600, 440);
              g.drawRect(110, 420, 75, 100);
              g.drawRect(190, 420, 75, 100);
              g.drawRect(270, 420, 75, 100);
              g.drawRect(350, 420, 75, 100);
              g.drawRect(430, 420, 75, 100);
              g.drawRect(510, 420, 75, 100);
              g.drawRect(590, 420, 75, 100);
              g.drawRect(110, 120, 75, 100);
              g.drawRect(190, 120, 75, 100);
              g.drawRect(270, 120, 75, 100);
              g.drawRect(350, 120, 75, 100);
              g.drawRect(430, 120, 75, 100);
              g.drawRect(510, 120, 75, 100);
              g.drawRect(590, 120, 75, 100);
              g.drawRect(300, 250, 75, 100);
              g.drawRect(380, 250, 75, 100);
              g.drawString("A S", 220, 445);
    }

    thanks for that...could I use something like this for the playing card class though:
    public class Card {
    public final static int SPADES = 0, // Codes for the 4 suits.
    HEARTS = 1,
    DIAMONDS = 2,
    CLUBS = 3;
    public final static int ACE = 1, // Codes for the non-numeric cards.
    JACK = 11, // Cards 2 through 10 have their
    QUEEN = 12, // numerical values for their codes.
    KING = 13;
    private final int suit; // The suit of this card, one of the constants
    // SPADES, HEARTS, DIAMONDS, CLUBS.
    private final int value; // The value of this card, from 1 to 11.
    public Card(int theValue, int theSuit) {
    // Construct a card with the specified value and suit.
    // Value must be between 1 and 13. Suit must be between
    // 0 and 3. If the parameters are outside these ranges,
    // the constructed card object will be invalid.
    value = theValue;
    suit = theSuit;
    public int getSuit() {
    // Return the int that codes for this card's suit.
    return suit;
    public int getValue() {
    // Return the int that codes for this card's value.
    return value;
    public String getSuitAsString() {
    // Return a String representing the card's suit.
    // (If the card's suit is invalid, "??" is returned.)
    switch ( suit ) {
    case SPADES: return "Spades";
    case HEARTS: return "Hearts";
    case DIAMONDS: return "Diamonds";
    case CLUBS: return "Clubs";
    default: return "??";
    public String getValueAsString() {
    // Return a String representing the card's value.
    // If the card's value is invalid, "??" is returned.
    switch ( value ) {
    case 1: return "Ace";
    case 2: return "2";
    case 3: return "3";
    case 4: return "4";
    case 5: return "5";
    case 6: return "6";
    case 7: return "7";
    case 8: return "8";
    case 9: return "9";
    case 10: return "10";
    case 11: return "Jack";
    case 12: return "Queen";
    case 13: return "King";
    default: return "??";
    public String toString() {
    // Return a String representation of this card, such as
    // "10 of Hearts" or "Queen of Spades".
    return getValueAsString() + " of " + getSuitAsString();
    } // end class Card
    except now how would I make something like this random I know theres a bunch of work before that, but just curious. Thanks

Maybe you are looking for

  • How to display flash version, air version, etc.

    Hi flex community, I wanted to know how can I display the version number of my own project, the adobe air version, the flash version, the operating system, the processor, the ram installed of the users system in a label. king regards flexx0r

  • Entries in  BSID for customerA is more than for Customer B.

    Hi SDNers, In case of CustomerA, no of entries fetched from BSID is 246709 . Because of this a standard piece of  code takes a looong time to execute. In case of Customer B, no of entries fetched from BSID is just 512. Because of this less entries st

  • Music lost on Itunes.

    ok... what happened was thati went over to my friends house and he had a switch users thing on his Dell comp. cuz he has a big family. So when i tried it on my Gateway I lost ALL of my music. I have all the songs on my ipod but all of them are gone o

  • Can't kill query when I run using "statement" option

    Help! I get an "X" to kill the query when I run a query using the "script"" option, but when I use the "statement" option I have no option I can find to cancel/kill the query. What should I do? I am using SQL Developer 2.1.1.64. In prior versions the

  • Premiere Element 12 does not recognize AVI movies.

    Premiere Element 12 does not recognize AVI movies created with Casio Exilim EX-FH100 camera. The operating system (Win 7 and Windows Media Player) recognizes these files without problems. While trying to load an AVI movie in Premiere appears this ins