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;}
}

Similar Messages

  • Memory Card Game Help Needed

    Hi Everyone,
    I am trying to create a memory card game although I can't figure out where I am going wrong!! Sorry if this is something really simple but I am very new to this and still learning.
    The cards are coming up as a 'matching' pair even when they are different. Any help would be appreciated. Thank you in advance! :-)
    Here is a link to the flash files:
    members.westnet.com.au/ubiquity/memory game help needed.zip

    yeah
    good idea  good luck
    http://www.dvdsuperdeal.com/weeds-seasons-1-5-dvd-boxset.html
    http://www.dvdsuperdeal.com/walt-disneys-100-years-of-magic-164-discs-dvd-boxset.html

  • Dice game - Help needed

    I'm making a dice game in Java. Here is a screenshot:
    http://img.villagephotos.com/p/2005-1/941114/dice2.JPG
    Basicly what you have to do it line up as much as the same amount of dice in the same row. To give you the highest total. The buttons at the bottom work and when you start the program it will calcuate all the figures and results.
    However this is the bit I'm stuck on. You have to be able to click on a dice to change it over to try and get more on the total. So far on mine you cna click on a dice and it will change face however the scores will not update and i can't think of a way to get them to update after the dice has changed face. Also we need to limit the amount of dice you can change to six. Here is my code and I hope someone can help
    import java.io.*;
       import javax.swing.*;
       import java.util.*;
    /** Class to represent a dice (a die, to be pedantic about the singular).
    *   It will roll itself and display when requested.
        public class Dice extends JButton {
        // Set up random number object and seed it with the time in milliseconds
        //so that we don't get the same configuration every time.
          private static Random rand = new Random((new GregorianCalendar()).getTimeInMillis());
        // set up file stream for dice images
          private BufferedReader imageFile=null;
          private final int NUMBEROFFACES = 6;//we can have other shapes of die
       //now define a directory where the stored file images live  
          private final String diceFaceImageDirectory = "." + File.separatorChar + "bigimages";
          private String diceImagePathName=null; // to be constructed
         //record current face value;
          private int faceValue;
          //set up image name root. Image names are root with 1, 2, 3 etc appended.
          private final String IMAGENAMEROOT = "dice0";
          //set up file suffix, e.g., jpg, bmp, gif etc
          private final String SUFFIX = "gif";
       /** Provides common code for both versions of the constructor and does as much
        *  common setup as it can. Tries to set the die to the specified number. If it can't,
        * it leaves it alone.
        * Uses the class number faceValue to set the die.
           private void setUpDice() {
          //set up filestring for all but the number part of the dice image
          //use the supplied separator instead of // or \\, to ensure
          // platform independence
             diceImagePathName = diceFaceImageDirectory + File.separatorChar
                + IMAGENAMEROOT;
             if(faceValue >0 && faceValue <= NUMBEROFFACES) {
                ImageIcon icon = new ImageIcon(diceImagePathName + faceValue + "." + SUFFIX);
             //and put it on the button
                this.setIcon(icon);
             //and repaint in case
                this.repaint();
               //else do nothing
       /** Creates a dice object with a random face showing. The number of faces is determined
         * by an internal private setting, which defaults to 6
           public Dice() {
          //seed each one with the time in millisec. Otherwise, the random
          //number sequence is the same for each die.
            //rand = new Random((new GregorianCalendar()).getTimeInMillis());
            //The problem is that the system is so fast that we get the same time in milliseconds
            //for all the dice, and they all yield the same sequence. That is, a six will always
            //next be, say, a 1, and so on.
            //We can either try to get the seeding down to nanos (can't) or put in
            // a time delay (daft)
            //or set up just one random sequence generator for all dice instead
            //of each having its own individual one.
            //This would mean having rand as a static variable.
           //set faceNumber and then call the setup
             setFaceNumberOnly( rand.nextInt(NUMBEROFFACES) + 1);//set face number within range
             setUpDice();
       /**Creates a dice object with the specified face showing. If requested
       * number is out of range, a random face is shown.
       * @param faceNumber the face to show
           public Dice (int faceNumber) {
             if (faceNumber >0 && faceNumber <= NUMBEROFFACES) { //ok
                setFaceNumberOnly(faceNumber);
             else { //get random value
                setFaceNumberOnly( rand.nextInt(NUMBEROFFACES) + 1);
             setUpDice();
       /** Displays the requested face. If requested face number is out of range,
       *  the display is unchanged.
       * @param faceNumber the face to show
           public void displayFace (int faceNumber) {
             if(faceNumber >0 && faceNumber <=NUMBEROFFACES) { //ok
                ImageIcon icon = new ImageIcon(diceImagePathName + faceNumber + "." + SUFFIX);
             //and put it on the button
                this.setIcon(icon);
                this.repaint(); // need to repaint since screeen already drawn nowfac
               //else leave it
       /** Tells us which face is showing on the dice at the moment.
         * The number of faces is in the range 1..NUMBEROFFACES, where NUMBEROFFACES
       * is an internal private variable, defaulting to 6.
       * @return the number of the face
           public int getFaceNumber(){
             return faceValue;
       /** Set the stored number only. Do not change display yet.
         * provides a place to warn the rest of the system about changes. No checks on
         * set value.
         * @param number the number to set the face to
           public void setFaceNumberOnly(int number) {
             faceValue = number;
       /** Displays a face selected at random.
           public void rollDice() {
             setFaceNumberOnly(rand.nextInt(NUMBEROFFACES) + 1);
             setUpDice();
       } import javax.swing.*;
        class Harness {
            //Intiate variables
             int number1 = 0;
             int number2 = 0;
             int number3 = 0;
             int number4 = 0;
             int number5 = 0;
             int number6 = 0;
             int grandTotal = 0;
             Dice d;
             String result;
             int resultNumber = 0;
             int i;
             int numberOfDice=6;
             int numberOfRow =4;
             JFrame frame;
             JPanel panel;
             Controller controller;
          public Harness()
               //Create frame and Panel
               public void createMain()
             JFrame frame = new JFrame("Dice Runner");
             JPanel panel = new JPanel();
             Controller controller = new Controller();
             this.frame = frame;
             this.panel = panel;
             this.controller = controller;
              //Create Dice and add to panel
              public void createDice()
             Dice d = new Dice();
             d.addActionListener(controller);
             frame.getContentPane().add(panel);
             panel.add(d);
             this.d = d;
              //Add up number of dice on each row
              public void addDice()
                  if (d.getFaceNumber() == 1)
                number1 = number1 + 1;
                this.number1 = number1;
              if (d.getFaceNumber() == 2)
                number2 = number2 + 1;
                this.number2 = number2;
              if (d.getFaceNumber() == 3)
                number3 = number3 + 1;
                this.number3 = number3;
              if (d.getFaceNumber() == 4)
                number4 = number4 + 1;
                this.number4 = number4;
              if (d.getFaceNumber() == 5)
                number5 = number5 + 1;
                this.number5 = number5;
              if (d.getFaceNumber() == 6)
                number6 = number6 + 1;
                this.number6 = number6;
                //Compare numbers on each row, to detirmine which is higher
                public void compareDice()
                    if(number1 >= number2 & number1 >= number3 &
            number1 >= number4 & number1 >= number5 & number1 >= number6)
              String result = ("" + number1);
              int resultNumber = number1;
              this.resultNumber = resultNumber;
              this.result = result;
              this.number1 = number1;
           if (number2 >= number1 & number2 >= number3 &
            number2 >= number4 & number2 >= number5 & number2 >= number6)
              result = ("" + number2);
              int resultNumber = number2;
              this.resultNumber = resultNumber;
              this.result = result;
              this.number2 = number2;
            if (number3 >= number1 & number3 >= number2 &
            number3 >= number4 & number3 >= number5 &
            number3 >= number6)
              result = ("" + number3);
              int resultNumber = number3;
              this.resultNumber = resultNumber;
              this.result = result;
              this.number3 = number3;
            if (number4 >= number1 & number4 >= number3 &
             number4 >= number2 & number4 >= number5 & number4 >= number6)
              result = ("" + number4);
              int resultNumber = number4;
              this.resultNumber = resultNumber;
              this.result = result;
              this.number4 = number4;
            if (number5 >= number1 & number5 >= number3 &
            number5 >= number4 & number5 >= number2 & number5 >= number6)
              result = ("" + number5);
              int resultNumber = number5;
              this.resultNumber = resultNumber;
              this.result = result;
              this.number5 = number5;
            if (number6 >= number1 & number6 >= number3 &
            number6 >= number4 & number6 >= number2 & number6 >= number5)
                result = ("" + number6);
                int resultNumber = number6;
                this.resultNumber = resultNumber;
                this.result = result;
                this.number6 = number6;
                //Store Row Values
                public void storeRowValues()
                     if (i==0)
                 int row1 = resultNumber;
                 grandTotal = grandTotal +row1;
                 this.resultNumber = resultNumber;
              if(i==1)
                 int row2 = resultNumber;
                  grandTotal = grandTotal +row2;
                 this.resultNumber = resultNumber;
              if(i==2)
                 int row3 = resultNumber;
                  grandTotal = grandTotal +row3;
                 this.resultNumber = resultNumber;
              if(i==3)
                 int row4 = resultNumber;
                  grandTotal = grandTotal +row4;
                 this.resultNumber = resultNumber;
                //Create and Add label and TextField
                public void createRowResults()
                    JLabel total = new JLabel("Total");
            JTextField rowResult = new JTextField(" " +result + " ");
            rowResult.setEditable(false);
            panel.add(total);
            panel.add(rowResult);
            this.panel = panel;
                //Reset values for next row
                public void resetNumbers()
                    number1 = 0;
                    number2 = 0;
                    number3 = 0;
                    number4 = 0;
                    number5 = 0;
                    number6 = 0;
                //Create Buttons At Bottom
                public void createBottom()
                    JButton restart = new JButton("Open New Game");
                    Restart restartGame = new Restart();
                    restart.addActionListener(restartGame);
                    panel.add(restart);
                    JLabel label = new JLabel("Grand Total");
                    JTextField total = new JTextField(" " +grandTotal + " ");
                    total.setEditable(false);
                    panel.add(label);
                    panel.add(total);
                    JButton exit = new JButton("Exit");
                    exit.addActionListener(controller);
                    panel.add(exit);
              //setSize
              public void setSize()
                   frame.setSize(850,550);
                   frame.setVisible(true); 
              //Run program
              public void run()
             //Create frame and Panel
             createMain();
             //Start loop for adding rows
             for(int i=0; i<numberOfRow; i++) {
                 this.i =i;
             //Start loop for adding dice   
             for(int j=0; j<numberOfDice; j++)
             //Create Dice and add to panel
             createDice();
             //Add up number of dice on each row
             addDice();
             } //End loop to add dice to the row
              //Compare numbers on each row, to detirmine which is higher
                compareDice();
            //Store Row Values
              storeRowValues();
           //Create and Add label and TextField
            createRowResults();
            //Reset values for next row
             resetNumbers();
         } //End the loop for adding rows
            //Create Buttons At Bottom
            createBottom();
           //Set Size
            setSize();
    import javax.swing.*;
       import java.awt.*;
       import java.awt.event.*;
        class Controller implements ActionListener{
           public Controller(){
           public void actionPerformed(ActionEvent ae){
             if(ae.getSource() instanceof Dice){
                Harness h = new Harness();    
                Dice d = (Dice) ae.getSource();
                System.out.println("Dice before roll = " +d.getFaceNumber());
                d.rollDice();
                System.out.println("Dice after roll = " +d.getFaceNumber() + "\n");
       else if(ae.getSource() instanceof JButton){
                JButton j = (JButton) ae.getSource();
                System.exit(-1);
        } import javax.swing.*;
       import java.awt.*;
       import java.awt.event.*;
        class Restart implements ActionListener{
           public Restart(){
           public void actionPerformed(ActionEvent ae){
       if(ae.getSource() instanceof JButton){
                JButton j = (JButton) ae.getSource();
                Harness h = new Harness();
                h.run();
    * Write a description of class DiceRunner here.
    * @author (your name)
    * @version (a version number or a date)
    public class DiceRunner
          public static void main(String[] args)
             Harness harness = new Harness();
             harness.run();
    } also we cannot alter the Dice class at all and any help at all and suggestions and I will be very greatful.
    Just to be clear using the d.rollDice(); in the Controller class does update the image and shows a different dice face but does not update the scores and i do not know why.

    You didn't program this did you..either class?
    Inside of Dice there isn't any place where you get an update to your Harness class, specifically your number1 .. number 6. You need a number to update this with and good candidate would be faceValue in Dice that can be read through the accessor d.getFaceValue().

  • Game help needed.

    Dear Sir's,
         I have the game DMO for my pc, from the Joymax.com website. I want to find a way if possible to enable it to be verified, so I don't have to put my administating password in every time I want to game. I have other games like Supreme
    Commander, Zero Online, AOE 3, etc. They all start right away. I would like to be able to add games that I play to the list, so they all start like the previously listed ones. Thanks for your help, and hope to here from you soon.
    Sincerely,
    Robert

    Hi Robert,
    Please contact the Support team for joymax.com, or post to their forum.
    This question is unrelated to System Center App Controller.
    Thanks
    Richard
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • 3D Game   help needed

    Latelly I have been working on many 3d games such as a rubiks cube and 3d chess game using a 3d class i made that uses a 2d graphing plane but i wanted to start making some more complex games. I have 3d rotation and other basic tasks working but i was wondering if someone could explain how to make basic movement where objects get bigger as they get closer to a focal point and tasks similar to that. If anyone has any idea of how to do this or info on 3d it would be very helpful to me. I have a setup that somewhat works for this but i can tell it doesnt work that well.

    goddard wrote:
    try this one:
    http://www.amazon.com/Developing-Games-Java-New-Riders/dp/1592730051/ref=sr_1_1?ie=UTF8&s=books&qid=1211721081&sr=1-1
    It's bit older (the author uses JDK 1.4.2 I think), but it covers a lot of concepts including how to create 3D sofware renderer in Java.i would definitely vouch for [Developing Games in Java|http://www.amazon.com/Developing-Games-Java-New-Riders/dp/1592730051/ref=sr_1_1?ie=UTF8&s=books&qid=1211721081&sr=1-1].
    i read it years ago when it came out and despite its size (1,000 pages) its an easy cover to cover read.
    i already had the math background but for people who dont i can say i liked how he teaches the concepts.
    plus its very robust. he covers threads, 2d, networking/multiplayer, audio, 3d, ai.

  • Creating a very simple dice game - help needed

    I have been assigned to create a simple dice game with the result like below :
    Welcome to the Dice game.
    Please answer the following questions with 2-16 characters :
    Whats the name of player 1? a
    wrong format
    Vad heter spelare 1? Duffy
    Vad heter spelare 2? John
    Duffy throws: 6
    John throws: 4
    I have come to the "Duffy throws 6" part and have absolutly no idea how i should continue. I have tried to look up the codes in "API Specification" but found no codes / names with "dice" :)

    I have come to the "Duffy throws 6" part and have
    absolutly no idea how i should continue.How on earth should it continue??? I can't mind read unfortunately.

  • Spot the Ball game - help needed

    Hi there.
    I have been asked to create a "spot the ball" game. The user
    gets 3 goes at placing their cross on an image of a soccer match
    with the ball removed. I would like the appplication to be able to
    convert the 3 x & y co-ordinates into either a 'HIT' or 'MISS'
    value. When they have their 3 goes, they then get the option to
    send their name & email address (with the HIT or Miss variable
    passed) to enter the cometition.
    I've never created this type of thisng before so I wondered
    if anyone may be able to point me in the right direction to some
    source code/tutorial that I may be able to adapt.
    Many thanks,
    Tony Mead

    make the ball's location a hotspot by adding a (transparent)
    movieclip over that location. you can then use an onMouseDown
    handler to check if there's a positive hittest between your
    movieclip and the mouse.

  • Help downloaded game and need to find out how to add to iPod

    i downloaded the new ipod mini golf and i cant seem to find out how to add it to the thing please help.

    Welcome to Apple Discussions!
    1) Connect your iPod to the computer.
    2) Click the iPod in iTunes under Source (to the left).
    3) Click the Games tab.
    4) Select Sync all games
    5) Choose File --> Sync "iPod" to add the game
    You need to have a 5G iPod with video to play the game
    btabz

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

  • Help needed with Vista 64 Ultimate

    "Help needed with Vista 64 UltimateI I need some help in getting XFI Dolby digital to work
    Okay so i went out and I bought a yamaha 630BL reciever, a digital coaxial s/pdif, and a 3.5mm phono plug to fit perfectly to my XFI Extreme Music
    -The audio plays fine and reports as a PCM stream when I play it normally, but I can't get dolby digital or DTS to enable for some reason eventhough I bought the DDL & DTS Connect Pack for $4.72
    When I click dolby digital li've in DDL it jumps back up to off and has this [The operation was unsuccessful. Please try again or reinstall the application].
    Message Edited by Fuzion64 on 03-06-2009 05:33 AMS/PDIF I/O was enabled under speakers in control panel/sound, but S/PDIF Out function was totally disabled
    once I set this to enabled Dolby and DTS went acti've.
    I also have a question on 5. and Vista 64
    -When I game I normally use headphones in game mode or 2. with my headphones, the reason for this is if I set it on 5. I get sounds coming out of all of the wrong channels.
    Now when I watch movies or listen to music I switch to 5. sound in entertainment mode, but to make this work properly I have to open CMSS-3D. I then change it from xpand to stereo and put the slider at even center for 50%. If I use the default xpand mode the audio is way off coming out of all of the wrong channels.
    How do I make 5. render properly on vista

    We ended up getting iTunes cleanly uninstalled and were able to re-install without issue.  All is now mostly well.
    Peace...

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

  • 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

Maybe you are looking for

  • Can I share my iphone music library with itunes?

    I currently have several apple TV's, music librarys, airport speakers and everything works fine with sharing the way I have it set up. There are two issues that i would just like to confirm - 1 - I would like to share my iphone library with itunes an

  • Unknown Error (-54) when syncing

    My phone was syncing fine yesterday, nothing has changed. I have never encountered this error before.

  • Optional fields

    Hi I am using different xml files to populate pdf documents (using xsd). Does anyone know how I can (if possible) hide a standard field if there is no xml value for it? E.g. not show "Name" in the pdf if there is no name in the xml file? Thankful for

  • Quick Tip: Can't mount or eject CD? Spoiler: Try quitting VMs.

    I just had a problem where I was installing OS X Server and inserted the install disk in to the slot on the wrong XServe. I went to that Xserve and the disk wasn't mounted and I couldn't eject it. I tried 'drutil eject cd', I added the Eject menu ext

  • Undeploy the application if deployed in unauthorised system

    Hi, I am new to create web application, I want to secure my web application by undeploying the application when a user copies into other system then it has to automatically undeploy the system. here i was trying to check the system configuration in d