请问一下各位大佬,我的这段代码最后的f();方法为什么不执行,多谢啦
//代码里的Course类和Student类都是和视频里一样的
package shili;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class StudentTest {
public List<Course> a;
public StudentTest() {
this.a=new ArrayList<Course>();
}
public void addCourse() {
Course cr1=new Course("1","米饭");
Course cr2=new Course("2","包子");
Course cr3=new Course("3","饼");
Course cr4=new Course("4","饺子");
Course cr5=new Course("5","馒头");
Course cr6=new Course("6","寿司");
Course cr7=new Course("7","鸡腿");
a.add(cr1);
a.add(cr2);
a.add(cr3);
a.add(cr4);
a.add(cr5);
a.add(cr6);
a.add(cr7);
}
public void forec() {
for(Object k:a) {
Course cr=(Course) k;
System.out.println(cr.id+cr.name);
}
}
public static void main(String[] args) {
StudentTest xc=new StudentTest();
System.out.println("本餐厅有以下主食:");
xc.addCourse();
xc.forec();
Student student=new Student("1","小明");
System.out.println("请"+student.name+"选餐:");
Scanner xh=new Scanner(System.in);
for(int i=0;i<3;i++) {
System.out.println("请输入食物序号:");
int one=xh.nextInt();
for(Course cr:xc.a) {
if(cr.id.equals(xh)) {
student.courses.add(cr);
}
}
}
xc.f(student);
}
public void f(Student student) {
for(Course cr:student.courses) {
System.out.println(cr.id+cr.name);
}
}
}