importjava.util.HashMap;importjava.util.List;importjava.util.Map;importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[] args){// poker.output();// System.out.println();// System.out.println();// poker.shuffle();// poker.output();// System.out.println();// System.out.println();// List<Card> hand = poker.getOneHand();// System.out.println(hand);// String type = poker.getHandType(hand);// System.out.println(type);Poker poker =newPoker();Map<String,Integer> mapPrize =newHashMap<>();
mapPrize.put("同花顺",100);
mapPrize.put("四条",25);
mapPrize.put("满堂红",10);
mapPrize.put("同花",5);
mapPrize.put("顺子",4);
mapPrize.put("三带一",3);
mapPrize.put("两对",2);
mapPrize.put("一对",0);
mapPrize.put("杂牌",-1);// System.out.println(mapPrize.get(type));Scanner scanner =newScanner(System.in);int score =10;while(score >0){System.out.println("-----------------------");System.out.println("your current score: "+ score);System.out.println("please bet your score(1-5):");int bet =Integer.valueOf(scanner.nextLine());
score -= bet;List<Card> hand = poker.getOneHand();System.out.println(hand);System.out.println("please input card no what you want to change(0 for exit)\n, input enter key if you do not change any card");String info = scanner.nextLine();if(info.equals("0")){break;}elseif(info.isEmpty()){//一张牌也不换;}else// 1 3 5{String[] arr = info.split(" ");for(int i =0; i < arr.length; i++){int card_no =Integer.parseInt(arr[i]);
card_no--;
hand.remove(card_no);
hand.add(card_no, poker.getOneCard(5+i));}}System.out.println(hand);String type = poker.getHandType(hand);System.out.println(type);int prize = mapPrize.get(type);System.out.println(prize*bet);
score += prize*bet;}}}
输出
you current score is 5
[方片A, 梅花Q, 红桃K, 黑桃Q, 方片K]
please input card no what you want to change (0 to exit)
, if you do not want to change any card, pleas input enter
1 2 4
[方片Q, 红桃Q, 红桃K, 红桃J, 方片K]
两对
you win 2 score
you current score is 6
[黑桃A, 红桃J, 方片10, 黑桃Q, 梅花10]
please input card no what you want to change (0 to exit)
, if you do not want to change any card, pleas input enter
1 2 4
[红桃K, 红桃A, 方片10, 红桃10, 梅花10]
三带一
you win 3 score
you current score is 8
[方片9, 梅花K, 梅花10, 黑桃J, 红桃A]
please input card no what you want to change (0 to exit)
, if you do not want to change any card, pleas input enter
0
you got max score is 8