第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

運行幾十次,總會出一次錯誤的比較大小

運行幾十次,總會出一次錯誤的比較大小

Meng7y 2017-07-07 20:24:29
public class PokerGame {?? ?List<Poker> pokers = new ArrayList<>();?? ?public PokerGame() {?? ??? ?int count = 13;?? ??? ?for(int i = 14; i > 1 ; i--,count--){?? ??? ??? ?String pString = i+"";?? ??? ??? ?if (i == 11){?? ??? ??? ??? ?pString = "J";?? ??? ??? ?}?? ??? ??? ?if (i == 12){?? ??? ??? ??? ?pString = "Q";?? ??? ??? ?}?? ??? ??? ?if (i == 13){?? ??? ??? ??? ?pString = "K";?? ??? ??? ?}?? ??? ??? ?if (i == 14){?? ??? ??? ??? ?pString = "A";?? ??? ??? ?}?? ??? ??? ?Poker[] spade = new Poker[count];?? ??? ??? ?//《錯誤日志》上面申請的是count長度的數(shù)組,但是數(shù)組是從零開始的,所以最大的數(shù)組下標(biāo)應(yīng)該是count減一?? ??? ??? ?spade[count-1] = new Poker();?? ??? ??? ?spade[count-1].setPokerFaces(pString);?? ??? ??? ?spade[count-1].setFlowerColor("黑桃");?? ??? ??? ?pokers.add(spade[count-1]);?? ??? ?}?? ??? ?for(Poker p:pokers){?? ??? ??? ?System.out.println(p.getFlowerColor()+p.getPokerFaces());?? ??? ?}?? ?}?? ??? ?public void playGame(){?? ??? ?Player p1 = new Player();?? ??? ?@SuppressWarnings("resource")?? ??? ?Scanner input = new Scanner(System.in);?? ??? ?System.out.println("請輸入第一位玩家的姓名:");?? ??? ?p1.setName(input.next());?? ??? ?Player p2 = new Player();?? ??? ?@SuppressWarnings("resource")?? ??? ?Scanner input2 = new Scanner(System.in);?? ??? ?System.out.println("請輸入第二位玩家的姓名:");?? ??? ?p2.setName(input2.next());?? ??? ??? ??? ?Random random = new Random();?? ??? ?int r = (random.nextInt(12));?? ??? ?String p1hand = pokers.get(r).getFlowerColor() + pokers.get(r).getPokerFaces();?? ??? ?p1.setHandPoker(p1hand);?? ??? ?pokers.remove(r);?? ??? ??? ??? ?Random random2 = new Random();?? ??? ?int r2 = (random2.nextInt(12));?? ??? ?String p2hand = pokers.get(r2).getFlowerColor() + pokers.get(r2).getPokerFaces();?? ??? ?p2.setHandPoker(p2hand);?? ??? ?pokers.remove(r2);?? ??? ??? ??? ?if(r < r2){?? ??? ??? ?System.out.println("玩家" + p1.getName() + "獲得勝利!");?? ??? ?}else {?? ??? ??? ?System.out.println("玩家" + p2.getName() + "獲得勝利!");?? ??? ?}?? ??? ??? ??? ?System.out.println("玩家" + p1.getName() + "的手牌是:" + p1.getHandPoker());?? ??? ?System.out.println("玩家" + p2.getName() + "的手牌是:" + p2.getHandPoker());?? ?}?? ??? ?public static void main(String[] args) {?? ??? ?PokerGame pokerGame? = new PokerGame();?? ??? ?pokerGame.playGame();?? ?}}
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1481 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號