📄 pokerkernal.java~28~
字号:
package poker;/** * <p>Title: 斗地主</p> * <p>Description: 核心算法</p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author 李艳生 * @version 1.0 */import java.util.*;public class PokerKernal { //打过的牌 public static Vector postCards = new Vector(); //每个玩家手中的牌 public static Vector oneCards = new Vector(); public static Vector twoCards = new Vector(); public static Vector threeCards = new Vector(); //选中的牌 public static Vector selectCards = new Vector(); //游戏状态:status = false表示没有开始 public static boolean status = false; //地主:确定第一个取牌人和叫叫牌人 public static String master; //叫牌价 public static int score = 0; //玩家 public static Player one = new Player(),two = new Player(),three = new Player(); //是否发完牌:true表示发完牌 public static boolean posted; //是否确定了拿牌人:true表示确定 public static boolean take; public PokerKernal() { } //整理玩家手中牌 public static void sortOneCards(){ Card c = new Card(); int k =0 ; //选择排序法 for(int i=0;i<19;i++){ k = i; for(int j=i+1;j<20;j++){ if(((Card)oneCards.get(k)).getDot()<((Card)oneCards.get(j)).getDot()){ k = j; } } if(k!=i){ c = (Card)oneCards.get(i); oneCards.setElementAt(oneCards.get(k),i); oneCards.setElementAt(c,k); } } } public static void sortTwoCards(){ Card c = new Card(); int k =0 ; //选择排序法 for(int i=0;i<19;i++){ k = i; for(int j=i+1;j<20;j++){ if(((Card)twoCards.get(k)).getDot()<((Card)twoCards.get(j)).getDot()){ k = j; } } if(k!=i){ c = (Card)twoCards.get(i); twoCards.setElementAt(twoCards.get(k),i); twoCards.setElementAt(c,k); } } } public static void sortThreeCards(){ Card c = new Card(); int k =0 ; //选择排序法 for(int i=0;i<19;i++){ k = i; for(int j=i+1;j<20;j++){ if(((Card)threeCards.get(k)).getDot()<((Card)threeCards.get(j)).getDot()){ k = j; } } if(k!=i){ c = (Card)threeCards.get(i); threeCards.setElementAt(threeCards.get(k),i); threeCards.setElementAt(c,k); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -