Package com.company;
public class Main {public
static void Main (string[] args) {
//1. Mr. 52 Cards
Poke Poke = new Poke ();
Poke.makecards ();
2. The generated poker will be printed out
poke.showcards ();
3. Shuffle
poke.shuffle ();
4. Print the card after washing
System.out.println ();
System.out.println ("\ n" + "after Shuffle");
Poke.showcards ();
System.out.println ();
Get a hand
card[] handcards = Poke.gethandcards ();
for (card c:handcards) {
System.out.println (c);
}
Judging card type
poke.judgecardtype (handcards);
}
Package com.company;
/** * Defines a class of poker, has a suit attribute, and has the properties of a card face * Created by TTC on 2017/7/1.
* * Public class Card {private String color; Private integer value;//the variable public String getcolor () of the integer type is defined as the value of the form () {return Colo
R
public void SetColor (String color) {this.color = color;
Public Integer GetValue () {return value;
The public void SetValue (Integer value) {this.value = value;
//rewrite the Card class tostring method, can print "J", "Q", "K", "A" public String toString () {String strvalue = Value.tostring ();
Switch (strvalue) {case "1": strvalue = "A";
Break
Case "one": strvalue = "J";
Break
Case "a": strvalue = "Q";
Break
Case "a": strvalue = "K";
Break
Default:break;
} return color+strvalue; }
}
Package com.company;
Import java.util.*;
/** * Poker Functional class * Created by TTC on 2017/7/1.
* * public class Poke {string[]colors = {"Red peach", "spade", "Square piece", "Grass Flower"};
Integer[]values = {1,2,3,4,5,6,7,8,9,10,11,12,13};
Card [] cards = new CARD[52];
Define a method for producing poker, double for loop public void Makecards () {int index = 0; for (int i = 0;i<colors.length;i++) {for (int j = 0;j<values.length;j++) {Cards[index] = n
EW card ();
Cards[index].setcolor (Colors[i]);
Cards[index].setvalue (Values[j]);
index++;
} return;
///Show Poker method public void Showcards () {int index2 = 0;
for (card c:cards) {if (index2%13==0) {System.out.println ();
} System.out.print (C.tostring ());
index2++;
}///define Shuffle method public void Shuffle () {Random r = new Random (); for (int i = 0; i<cards.length;i++) {int index = R.nextint (i+1);
Card temp = cards[i];
Cards[i] = Cards[index];
Cards[index] = temp;
}//Defines the method of taking the hand card public card[] Gethandcards () {card[] handcards = new CARD[5];
for (int i = 0;i<5;i++) {Handcards[i] = cards[i];
return handcards; }//Judge the method of the card type public void Judgecardtype (cards [] handcards) {//Judge first whether the hand is the same flower Boolean bissamecolor = Fal
Se
Boolean Bisshunzi = false;
set<string> colorset = new hashset<> ();
for (int i = 0;i