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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

第七章綜合練習(xí)空指針異常問(wèn)題

第七章綜合練習(xí)空指針異常問(wèn)題

package gamed;import java.util.ArrayList;import java.util.Collections;import java.util.List;import java.util.Random;import java.util.Scanner;import java.util.concurrent.SynchronousQueue;public class poker {?? ?private String col;?? ?private String num;?? ?List<poker> a = new ArrayList<poker>();?? ?List<player> playertocreate = new ArrayList<player>();?? ??? ?public poker(String col,String num){?? ?this.col=col;?? ?this.num=num;?? ?}?? ??? ?public poker() {?? ??? ?// TODO Auto-generated constructor stub?? ?}?? ?public String getCol() {?? ??? ?return col;?? ?}?? ?public void setCol(String col) {?? ??? ?this.col = col;?? ?}?? ?public String getNum() {?? ??? ?return num;?? ?}?? ?public void setNum(String num) {?? ??? ?this.num = num;?? ?}?? ??? ?public void creat(){?? ??? ?String[] col1 ={"黑桃","紅桃","梅花","方片"};?? ??? ?String[] num1 ={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};?? ?for(int i=0;i<col1.length;i++){?? ??? ?for(int j=0;j<num1.length;j++){?? ??? ??? ?poker b = new poker(col1[i],num1[j]);?? ??? ??? ?a.add(b);?? ??? ?}?? ??? ??? ?}?? ?System.out.println("撲克創(chuàng)建完成");?? ?System.out.println("您創(chuàng)建的撲克如下");?? ?for (poker po : a) {?? ??? ?System.out.println(po.col+po.num);?? ??? ?}?? ?}?? ??? ??? ??? ?public void flash(){?? ??? ?Collections.shuffle(a);?? ??? ?System.out.println("洗牌完成");?? ??? ?}?? ??? ??? ??? ?public void? Creatplayer(){?? ??? ?//List<player> playertocreate = new ArrayList<player>();??????? int i=0;??????? Scanner console = new Scanner(System.in);??????? while(i<2){?????? ??? ??? ?//try{?????? ??? ??? ?System.out.println("請(qǐng)輸入第"+(i+1)+"個(gè)玩家的姓名");?????? ??? ??? ?player player = new player();?????? ??? ??? ?console = new Scanner(System.in);?????? ??? ??? ?player.setName(console.next());?????? ??? ??? ?console = new Scanner(System.in);?????? ??? ??? ?try{?????? ??? ??? ?System.out.println("請(qǐng)輸入第"+(i+1)+"個(gè)玩家的ID");?????? ??? ??? ?player.setID(console.nextInt());?????? ??? ??? ?playertocreate.add(player);?????? ??? ??? ?i++;?????? ??? ??? ?}catch (Exception e) {?? ??? ??? ??? ?System.out.println("請(qǐng)輸入正確的玩家ID");?? ??? ??? ??? ?}?????? ??? ??? ???????? }??????? for (player pl : playertocreate) {?? ??? ??? ?System.out.println("歡迎"+pl.getName()+"您的ID為"+pl.getID());?? ??? ?}?????? ??? ???? }??? ?? ?? ??? ??? ??? ?public void sendpoker(){?? ??? ?for (player player : playertocreate) {?? ??? ??? ?System.out.println(player.getName()+"拿牌");?? ??? ??? ?Random random = new Random();?? ??? ??? ?for(int i=0;i<2;i++){?? ??? ??? ??? ?player.playerpoker.add(i, (poker)a.get(random.nextInt(a.size())));?? ??? ??? ??? ?System.out.println(player.getName()+"拿到的"+(i+1)?? ??? ??? ??? ??? ??? ?+"牌為"+(poker)player.playerpoker.get(i));?? ??? ??? ?}?? ??? ?}?? ??? ??? ?}public void match(){?? ??? ?}?? ?public static void main(String[] args) {?? ?poker p = new poker();?? ?p.creat();?? ?p.flash();?? ?p.Creatplayer();?? ?p.sendpoker();}?? ?}加黑部分運(yùn)行的時(shí)候?yàn)槭裁磿?huì)拋一個(gè)空指針異常沒(méi)太想明白
查看完整描述

目前暫無(wú)任何回答

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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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