| |

VerySource

 Forgot password?
 Register
Search
View: 969|Reply: 7

Find JAVA Poker Code

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-10 15:40:01
| Show all posts |Read mode
It's very simple. Each time you deal 5 cards, the ratio is enough.
For example, the straight is greater than the pair, and the pair is greater than the scatter.
A total of 54 cards, re-licensed if less than 10
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-7 12:15:01
| Show all posts
How to calculate two Secretary tokens
Reply

Use magic Report

1

Threads

51

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-2-18 10:00:01
| Show all posts
Google Baidu
Reply

Use magic Report

0

Threads

23

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-7-29 22:00:01
| Show all posts
You didn’t say how Pharaoh would judge, so I can’t do anything. I wrote one. I hope it will help you. This program does not compare cards. First of all, I don’t know how you want to compare the two cards Pharaoh. I'm too lazy to write. Please see.


import java.util.*;


class Pockers extends Stack //This is a class of a deck of cards. There are 54 cards in it. The wash method is to shuffle the cards and inherit the stack, because the card is originally taken from the top one.
{
  public Pockers()
  {
    this.add(new Pocker(Pocker.JOCKER_BLACK));
    this.add(new Pocker(Pocker.JOCKER_RED)); //Add two old kings
    for(int i=2;i<=14;i++)
      for(int j=1;j<=4;j++)
      {
        this.add(new Pocker(i,j)); //Add card, j is suit
      }
    for(int i=1;i<=4;i++) wash(); //shuffle four times
  }
  public void wash()
  {
    Pocker temp=null;
    Random r=new Random();
    for(int i=0;i<54;i++)
    {
      temp=(Pocker)this.pop();
      this.insertElementAt(temp,Math.abs(r.nextInt()%54)); //Insert the i-th card into this set of cards at random positions
    }
  }
  public boolean needReWash() // Determine whether to rewash.
  {
    return this.elementCount<10;
  }
  
  public void output() //This is for writing program testing.
  {
    for(int i=0;i<54;i++)
    {
      ((Pocker)this.get(i)).output();
    }
  }
}

class Player //Player class
{
  String name;
  public Pocker[] recieve=new Pocker[5];
  public Player(int i)
  {
    if(i==1) name="player1";
    else name="player 2";
  }
  public void getPocker(Pocker pocker,int queue) //get a card
  {
    recieve[queue]=pocker;
  }
  public void showPocker() //Display the player's card
  {
    System.out.println(name+"The card is:");
    for(int i=0;i<5;i++)
    {
      recieve[i].output();
    }
    System.out.println();
  }
}

class Judge //Judge
{
  public static void compare(Player player1,Player player2) //Compare player's cards
  {
   
  }
  public static void give(Pockers p,Player p1,Player p2) //Deal cards.
  {
    for(int i=0;i<5;i++)
    {
      p1.getPocker((Pocker)p.pop(),i);
      p2.getPocker((Pocker)p.pop(),i);
    }
  }
}

class Pocker //A card class
{
  static int BLOCK=1;
  static int FLOWER=2;
  static int HEART=3;
  static int PEACH=4; //The suit field originally intended to be used, but unfortunately it was not used.
  static int JOCKER_RED=20;
  static int JOCKER_BLACK=10;
  
  public int number,flower;
  public Pocker(int number,int flower) //Construction 1, which is a construction of general cards
  {
    this.number=number;
    this.flower=flower;
  }
  public Pocker(int flower) //This structure is used to construct the jocker card.
  {
    this(100,flower);
  }
  public void output() //Output this card, here is the "(size, suit)" format.
  {
    System.out.print("("+number+","+flower+")");
  }
}

public class a //The main function of the game.
{
  public static void main(String[] args)
  {
    Pockers p=new Pockers();
    Player player1=new Player(1);
    Player player2=new Player(2);
    Judge.give(p,player1,player2);
    player1.showPocker();
    player2.showPocker();
    /*
    Judge.compare(player1,player2); //There is no comparison function written here, this is a waste of time, I am too lazy to write it, and you did not explain how to calculate the JOCKER card, and write it for nothing. You have to write it yourself. Haha, the method is written in the compare method of the Judge class, you can change it appropriately, or create a new class or something. Haha.
    */
  }
}
Reply

Use magic Report

0

Threads

23

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-7-29 22:15:01
| Show all posts
The result can only be this: because there is no comparison card

Player 1's cards are:
(2,4)(7,2)(13,4)(2,1)(9,3)
Player 2's cards are:
(4,3)(6,1)(4,2)(9,4)(11,1)
.......
Reply

Use magic Report

0

Threads

9

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-8-4 21:45:01
| Show all posts
mark
Reply

Use magic Report

2

Threads

11

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-8-5 09:15:02
| Show all posts
Completely object-oriented, learning
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-1 15:15:01
| Show all posts
There are gains written number!!!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list