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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

幫我看下為什么只能打印2門(mén)選擇課程?

package aaa;


import java.util.HashSet;

import java.util.Set;


public class student {

? ? ? ? public String id;

? ? ? ? public String name;

? ? ? ? public ? Set<coure> coures;

? ? ? ??

? ? ? ? public student(){}

? ? ? ? public student(String id,String name)

? ? ? ? {

? ? ? ? this.id=id;

? ? ? ? this.name=name;

? ? ? ? this.coures=new HashSet<coure>();

? ? ? ? }

? ? ? ??

}

package aaa;


public class coure {

public String id;

? ? ?public String name;

? ? ?public coure(){}

? ? ?public coure(String id,String name)

? ? ?{

? ? this.id=id;

? ? this.name=name;

? ? ?

? ? ?}

}

package aaa;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.Scanner;


public class testset {

? ? public List<coure> coureselect;

? ? public testset()

? ? {

? ? this.coureselect=new ArrayList<coure>();

? ? }

? ??

? ? public void testadd()

? ? {

? ? coure c1=new coure("1", "離散數(shù)學(xué)");

? ? coureselect.add(c1);

? ?

? ? coure c2=new coure("2", "大學(xué)語(yǔ)文");

? ? coureselect.add(0, c2);

? ?

? ? coure[] c3={new coure("4", "物理學(xué)"),new coure("5", "生物學(xué)")};

? ? coureselect.addAll(Arrays.asList(c3));

? ?

? ? coure[] c4={new coure("6", "四級(jí)英語(yǔ)"),new coure("7", "計(jì)算機(jī)")};

? ? coureselect.addAll(0, Arrays.asList(c4));

? ? }

? ?

? ??

? ? public void testforeach()

? ? {

? ? for(coure cc:coureselect)

? ? {

? ? System.out.println("課程查詢:"+cc.id+" ?"+cc.name);

? ? }

? ? }

? ??

? ??

? ??

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

testset t=new testset();

t.testadd();

t.testforeach();

student s=new student("1","小明");

System.out.println("歡迎"+s.name+"選課");

Scanner input=new Scanner(System.in);

for(int i=0;i<4;i++)

{

System.out.println("請(qǐng)輸入課程ID:");

String coureid=input.next();

for(coure cr:t.coureselect)

{

if(cr.id.equals(coureid))

{

s.coures.add(cr);

}

}

}

t.foreachset(s);

}

? ? public void foreachset(student s)

? ? {

? ? for(coure cr:s.coures)

? ? {

? ? System.out.println("選擇課程:"+cr.id+" "+cr.name);

? ? }

? ? }

}

無(wú)論小明選擇幾門(mén)課最后都只打印了兩門(mén)課程

正在回答

3 回答

http://img1.sycdn.imooc.com//58bbbca600011f3902410507.jpg把你的代碼運(yùn)行了一下? 沒(méi)有問(wèn)題?。???

0 回復(fù) 有任何疑惑可以回復(fù)我~

你這里面沒(méi)有ID為3 的課程

我也不是大神? 我跟你一樣都是初學(xué)者

0 回復(fù) 有任何疑惑可以回復(fù)我~

?。靠墒俏耶?dāng)時(shí)運(yùn)行時(shí)有問(wèn)題,那我在運(yùn)行試下,我又有一個(gè)問(wèn)題了,我想做一個(gè)抽獎(jiǎng)的小游戲,結(jié)果卡在第一步了,就是必須注冊(cè)成為會(huì)員才能抽獎(jiǎng),而原本就是會(huì)員的可以直接登錄抽獎(jiǎng),然后登錄這一步用戶很可能輸錯(cuò)嗎,我就想用一個(gè)循環(huán),知道賬號(hào)和密碼全對(duì)才能進(jìn)行下一步,但我不知道循環(huán)該 怎么用了,原本打的代碼被我一氣之下給刪了。大神有什么意見(jiàn)嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

辜谷谷 提問(wèn)者

為什么我運(yùn)行還是有問(wèn)題啊 課程查詢:6 四級(jí)英語(yǔ) 課程查詢:7 計(jì)算機(jī) 課程查詢:2 大學(xué)語(yǔ)文 課程查詢:1 離散數(shù)學(xué) 課程查詢:4 物理學(xué) 課程查詢:5 生物學(xué) 歡迎學(xué)生小明選課 請(qǐng)輸入課程ID 3 請(qǐng)輸入課程ID 4 請(qǐng)輸入課程ID 1 選擇課程:4物理學(xué) 選擇課程:1離散數(shù)學(xué)
2017-03-06 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

幫我看下為什么只能打印2門(mén)選擇課程?

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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