鬥地主排序版

2021-10-17 14:43:34 字數 1182 閱讀 7847

原理**:

案例演示:

模擬鬥地主洗牌和發牌看牌,牌有序

一副牌 54 張牌

*/public class landlord;

string nums = ;

int index = 0;

for (string num : nums)

}hm.put(index, "大鬼");

indexs.add(index);

index++;

hm.put(index, "小鬼");

indexs.add(index);

//洗牌

collections.shuffle(indexs);

//發牌

treeset星仔 = new treeset();

treeset刀仔 = new treeset();

treeset高進 = new treeset();

treeset底牌 = new treeset();

//鬥地主3個人 留一副底牌

//發牌:一人一張輪流張發

// 一次數好發給你

// 星仔 = pokerbox.sublist(0, 17);

//發牌:一人一張輪流發

//星仔:0 3 6 9 12 取餘 0

//刀仔: 1 4 7 10 13 取餘 1

//高進: 2 5 8 11 14 取餘 2

for (int i = 0; i < indexs.size(); i++) else if (i % 3 == 0) else if (i % 3 == 1) else

}//看牌,鍵找值

lookpoker("星仔", 星仔, hm);

lookpoker("刀仔", 刀仔, hm);

lookpoker("高進", 高進, hm);

lookpoker("底牌", 底牌, hm);

}private static void lookpoker(string name, treesetset, hashmaphm)

system.out.println();}}

鬥地主簡單版

案例分析 1.準備牌 54張牌儲存到乙個集合中 特殊牌 大王,小王 其他52張牌 2.洗牌 3.發牌 要求 1人17張牌,剩餘3張作為底牌,一人一張輪流發牌 集合的索引 3 4.看牌 直接列印集合,遍歷儲存玩家和底牌的集合 public class doudizhu string numbers 先...

鬥地主排序個人解法實現

個人想不出對於鬥地主這種牌大小有特殊情況時利用ascii碼的更優解法,所以用了窮舉賦值的笨辦法。arraylisty new arraylist for string a x else if a.equals 小王 else else if a.substring 1,2 equals 2 else...

鬥地主發牌

鬥地主的發牌 a 鬥地主的發牌 實現模擬鬥地主的功能 1.組合牌 2.洗牌 3.發牌 4.看牌 public class doudizhu 定義4個花色陣列 string colors 定義整數變數,作為鍵出現 int index 2 遍歷陣列,花色 點數的組合,儲存到map集合 for strin...