生活随笔
收集整理的這篇文章主要介紹了
斗地主源代码!
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
*簡單的斗地主程序代碼
1.洗牌、發牌(留三張)
*
public static void main(String
[] args
) {List
<Integer> list
= new ArrayList<>();Map
<Integer,String> map
= new HashMap<>();String
[] color
={"?","◆","?","?"};String
[] number
={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};int index
=0;for (String num
:number
){for (String co
: color
){map
.put(index
,co
+num
);list
.add(index
);index
++;}}map
.put(52,"小王");map
.put(53,"大王");list
.add(52);list
.add(53);Collections
.shuffle(list
);List
<Integer>p1
= new ArrayList();List
<Integer>p2
= new ArrayList<>();List
<Integer>p3
= new ArrayList<>();List
<Integer>bottom
= new ArrayList<>();for (int i
= 0; i
<list
.size() ; i
++) {if (i
<3){bottom
.add(list
.get(i
));}else if (i
%3==0){p1
.add(list
.get(i
));}else if(i
%3==1){p2
.add(list
.get(i
));}else {p3
.add(list
.get(i
));}}Collections
.sort(p1
);Collections
.sort(p2
);Collections
.sort(p3
);Collections
.sort(bottom
);show("老王", p1
, map
);show("老張", p2
, map
);show("宋哲", p3
, map
);show("底牌", bottom
, map
);}private static void show(String name
, List
<Integer> list
, Map
<Integer, String> map
) {System
.out
.print(name
+": ");for(Integer in
:list
){String value
= map
.get(in
);System
.out
.print(value
+" ");}System
.out
.println();}
java單機斗地主源碼,希望大家互相學習多多支持哦,不好的地方體諒哈!
進步,意味著目標不斷前移,階段不斷更新,它的視影不斷變化。
總結
以上是生活随笔為你收集整理的斗地主源代码!的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。