亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

分享一下我的代碼

import?java.util.ArrayList;

import?java.util.Random;


public?class?Pokegame{

????ArrayList<Poke>?cards?=?new?ArrayList<Poke>();

????public?void?init(){

????????for(int?i?=?1;i<=13;i++){

????????????for(int?j?=1;j<=4;j++){

????????????????cards.add(new?Poke(i,j));

????????????}

????????}

????}

????public?void?flushCards(){

????????Random?random?=?new?Random();

????????for(int?i?=0;i<100;i++){

????????????Poke?a??=?cards.get(random.nextInt(52));

????????????cards.remove(a);

????????????cards.add(a);???

????????}

????}

????public?void?show(){

????????for?(Poke?poke?:?cards)?{

????????????System.out.println(poke);

????????}

????}

????public?static?void?main(String[]?args)?{

????????Pokegame?game?=new?Pokegame();

????????game.init();

????????game.flushCards();

????????game.show();

????}

}


正在回答

3 回答

Collections.shuffle(list);不是更簡潔一點嗎?

1 回復 有任何疑惑可以回復我~

不秀,利用set的無序性就可以很簡單的做到打亂了

1 回復 有任何疑惑可以回復我~

感覺我這個洗牌很秀

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

分享一下我的代碼

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號