basic knowledge of the points
more popular poker games in the world
Get rid of a deck of cards of the size king, total cards
The point does not distinguish the color, where A---- of the poker itself is the number of points J Q K for ten points
distinguish between the banker and the idle home, where the leisure home can be a priority card and the banker in the same size as the number of idle points, the dealer wins, when there is a party points more than four points, the other party will automatically win, the dealer's points if it happens to be a Point, then the dealer directly wins, Other cases win with a large number of points
Process design:
Man-machine versus mode!
1 by user input choice for village or idle, the computer automatically become the other party
2 randomly send two cards to both sides
3 Ask the busy house whether to card, until the busy home no longer want or the occurrence of a violent point
4 Ask the dealer to sign, until the dealer no longer want to or the point of violence or just a few points so far
5 Compare Games win or lose
6 Ask if you want to continue
7 statistical victories
Technical questions:
1. randomly issued when the card is issued
2. Licensing out also to determine whether this card has been sent! If it has already been sent, then it is necessary to re-randomly send another card, to ensure the uniqueness of the card
3. When you send a card to the computer to consider the problem of AI ! Let the logic of the computer mimic the human mind a little .
Main class:
Import Java.util.scanner;public class Cardtest {public static void Main (string[] args) {Scanner sc = new Scanner (Syst em.in); int win = 0;int lose = 0;while (true) {System.out.println ("make banker 1/busy home 2?"); int num = Sc.nextint (); if (num = = 1) {System.out.println ("you choose to be the Banker"); Ruler r = new Ruler (); int N=r.play (); if (n==0) { //banker wins win++; } else lose++;} else if (num = 2) {System.out.printl N ("You choose to be a busy home"); Player P = new player (); int n= p.play (); if (n==1) { //home win win++; } else lose++;} else {System.out.println ("input error, re-enter");} System.out.println ("Whether to continue y/n"), if (Sc.next (). charAt (0) = = ' Y ') continue;else {System.out.println ("Game Over"); System.out.println ("Win:" +win); System.out.println ("Lose:" +lose); break;}}}
Import Java.util.random;public class Card {int index = 0;//Licensing index subscript string[] Card = {"Peach a", "Peach 2", "Hearts 3", "Pink 4", "Red Peach 5", "Red Peach 6 "," Red Peach 7 "," Hearts 8 ", " Red Peach 9 "," Hearts 10 "," Red Peach J "," Red Peach Q "," Red Peach k "," Spades a "," Spades 2 "," Spades 3 "," Spades 4 "," Spades 5 "," Spades 6 "," Spades 7 "," Spades 8 "," Spades 9 "," Spades 10 "," Spades J "," Spades Q "," Spades K "," Plum a "," Plum 2 "," Plum 3 "," Plum 4 "," Plum 5 "," Plum 6 "," Plum 7 "," Plum 8 "," Plum Blossom 9 "," Plum blossom 10 "," Plum Blossom J "," Plum blossom Q "," Plum blossom K ", "Square Piece A", "Square 2", "Square 3", "Square piece 4", "Square piece 5", "Square piece 6", "Square piece 7", "Square plate 8", "Square piece 9", "Square piece 10", "Square piece J", "Square piece Q", "square sheet K", ";p ublic Void Show () {for (int i = 0; I < 52; i++) {System.out.println (card[i]);}} Shuffle, disrupt the order of Cards public void Cutcards () {int index=0; Random rand = new Random (), for (int i = 0; i < i++) {int n = rand.nextint (52); String temp;temp = card[n];card[n] = card[51-n];card[51-n] = temp;}} Licensing, issued sequentially, starting from subscript 0 public String deal () {string c = Card[index];index++;return C;}}
public class Judgenum {public int judgestring (string num) {string word= num.substring (2), if (Word.equals ("A")) { return 1;} else if (num.substring (2). Equals ("J") | | Num.substring (2). Equals ("Q") | | Num.substring (2). Equals ("K") | | Num.substring (2). Equals ("ten")) {return;} else { int n= (int) num.substring (2). CharAt (0) -48;return n;}}}
Import Java.util.random;import Java.util.scanner;public class Player {/* * Choose to do a free home first hand you select: Free Home
Licensing Time: Free home: Red Peach k Square Slice 3
Banker: Spades 6 Plum 4 * Busy home to Card time:
Do you want a card (y/n)?
Y
Licensing: Spades A * do you want to card (y/n)?
Y Licensing: Plum 5 Busy home whether to card (y/n)?
N busy home no longer wants card:
Number of idle points: 19 points
Dealer Time:
Dealer to Card: Plum 5 * Dealer to Card: Spades 4
The dealer no longer wants the card:
Dealer points 19 Point Zhuang win * * * */Scanner sc= new Scanner (system.in); public int Play () {int playernum=0; int rulernum=0; String Player1; String Player2; String Ruler1; String Ruler2; Judgenum judge = new Judgenum (); Card c = new card (), C.cutcards ();p layer1 = C.deal ();p layer2 = C.deal (); System.out.println ("Licensing Time:"); System.out.println ("Busy home:" + player1 + "" + player2); Playernum=judge.judgestring (Player1) +judge.judgestring (player2); Ruler1 = C.deal (); ruler2 = C.deal (); System.out.println ("Banker:" + Ruler1 + "" + Ruler2); rulernum=judge.judgestring (Ruler1) +judge.judgestring (RULER2); System.out.println ("Busy House points:" +playernum); System.out.println ("Banker points:" +rulernum); System.out.println ("Busy home to Card time:"); Loop to card phase while (true) {System.out.println ("Do you want a card (y/n)?"); char w = sc.next (). charAt (0); if (w== ' Y ') {System.out.println ("The busy House continues to ask for cards"); String player3=c.deal (); System.out.println ("Busy house:" +player3); Playernum=playernum+judge.judgestring (PLAYER3); System.out.priNtln ("Busy House points:" +playernum), if (playernum>21) {System.out.println ("The player blew off, the dealer wins"); return 0;} } else if (w== ' N ') {System.out.println ("Idle home no longer wants cards, idle points:" +playernum); Break }}system.out.println ("Dealer Time"), while (true) {if (rulernum>=playernum) {System.out.println ("dealer no longer wants a card, dealer wins"); return 0 ; }else {System.out.println ("Dealer Time:"); String ruler3=c.deal (); System.out.println ("banker:" +ruler3); rulernum=rulernum+judge.judgestring (Ruler3); if (rulernum>21) { System.out.println ("Dealer points" +rulernum); System.out.println ("Dealer burst, idle home win"); return 1;} else if (rulernum>=playernum) {System.out.println ("Banker points:" +rulernum+ "Busy Home points:" +playernum); System.out.println ("banker wins"); return 0;}}}}
Import Java.util.scanner;public class Ruler {//Choose to make banker/* * Play home First card * */scanner sc = new Scanner (system.in);p ublic int Play () {int playernum = 0;int Rulernum = 0; String Player1; String Player2; String Ruler1; String Ruler2; Judgenum judge = new Judgenum (); Card c = new card (), C.cutcards ();p layer1 = C.deal ();p layer2 = C.deal (); System.out.println ("Licensing Time:"); System.out.println ("Busy home:" + player1 + "" + player2);p layernum = judge.judgestring (player1) + judge.judgestring (player2); r Uler1 = C.deal (); ruler2 = C.deal (); System.out.println ("Banker:" + Ruler1 + "" + ruler2); rulernum = judge.judgestring (ruler1) + judge.judgestring (ruler2); System.out.println ("Busy House points:" + playernum); System.out.println ("Banker points:" + rulernum); System.out.println ("Busy House to Card time:"), while (true) {String player3;if (playernum <rulernum) {System.out.println ("Busy House to Card"); Player3 = C.deal (); System.out.println ("Busy house:" + player3);p layernum = Playernum + judge.judgestring (PLAYER3);} else if (Playernum >) {System.out.println ("Free Home points:" + playernum); System.out. println ("The Idle house blew off, the dealer wins"); return 0;} else if (Playernum >=) {System.out.println ("no longer wants a card by the Idle House"); System.out.println ("Busy house points" + playernum); else {System.out.println ("Busy House to Card"); String player4 = C.deal (); System.out.println ("Busy home:" + player4);p layernum=playernum+judge.judgestring (PLAYER4); if (Playernum >) {System.out.println ("Free Home points:" + playernum); SYSTEM.OUT.PRINTLN ("The Idle house blew off, the banker wins"); return 0;}} Dealer Time System.out.println ("Dealer to Card Time:"); while (true) {System.out.println ("Banker's Card (y/n)"), char w = sc.next (). charAt (0); if (w = = ' Y ') {System.out.println ("dealer continues to sign"); String Ruler3 = C.deal (); System.out.println ("Banker:" + ruler3); rulernum = Rulernum + judge.judgestring (RULER3); System.out.println ("Banker points:" + rulernum); if (Rulernum >) {System.out.println ("dealer explodes, player wins"); return 1;}} else if (w = = ' N ') {System.out.println ("dealer no longer wants a card, dealer points:" + rulernum); break;}} if (rulernum >= playernum) {System.out.println ("banker wins"); return 0;} else {System.out.println ("Free Home wins"); return 1;} } }
21-Point Game Java implementation