package com.imooc.stu;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
public class setTest {
public List<Course> coursetoSelect;
public setTest() {
this.coursetoSelect = new ArrayList<Course>();
}
public void crAdd(){
Course[] cr = {new Course("1","语文"),new Course("2","数学"),new Course("3","英语"),new Course("4","物理"),new Course("5","生物")};
coursetoSelect.addAll(Arrays.asList(cr));
}
public void crDisplay() {
System.out.println("有如下待选课程:");
for(Course cr:coursetoSelect) {
System.out.println(cr.id + " " + cr.name);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
setTest st = new setTest();
st.crAdd();
st.crDisplay();
Student student = new Student("1","小明");
System.out.println("欢迎学生:" + student.name);
Scanner sc = new Scanner(System.in);
for(int i = 0;i<3;i++){
System.out.println("请输入选择课程ID:");
String scc = sc.next();
for(Course cr : st.coursetoSelect) {
if(cr.id.equals(scc)) {
student.courses.add(cr);
}
}
}
st.testForeach(student);
}
public void testForeach(Student student) {
for(Course cr : student.courses){
System.out.println(cr.id + "" + cr.name);
}
}
}