package com.course;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
public class TestList {
public List<Course> coursesToSelect;
public TestList(){
coursesToSelect = new ArrayList<Course>();
}
//initialize the course list
public void makeCoursesList(){
Course[] cr = {new Course("110", "c programming"), new Course("112", "advanced java"), new Course("301","unix"), new Course("205","introduce to HTML"), new Course("332","CSS base")};
coursesToSelect.addAll(Arrays.asList(cr));
}
//select 3 courses for a student
public void selectCourse(Student stu){
Scanner input = new Scanner(System.in);
String courseID;
for (int i=0;i<3;i++){
System.out.print("Please enter the course ID: ");
courseID = input.next();
for(Course cr: coursesToSelect){
if (cr.getID().equals(courseID)){
stu.courses.add(cr);
}
}
}
}
//display all the courses which were chosen by a student
public void displayStuCr(Student stu){
System.out.println(stu.getName()+", you already selected the following courses:");
for (Course cr:stu.courses){
System.out.println(cr.getID()+". "+cr.getName());
}
}
//display a list for all the available courses
public void displayAllCourses(){
System.out.println("Please select your courses from the following list:");
for (Course cr:coursesToSelect){
System.out.println(cr.getID()+". "+cr.getName());
}
}
public void welMessage(Student stu){
System.out.println(stu.getName()+" Welcome to our courses selection system!\n");
}
public static void main(String[] args){
TestList tl = new TestList();
Student stu = new Student("Vivian Wang","343293"); //initialize one student
tl.welMessage(stu);
tl.makeCoursesList();
tl.displayAllCourses();
tl.selectCourse(stu);
tl.displayStuCr(stu);
System.out.println("Thanks for using our course selection system!");
}