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); }} }
这里的Course类和Student类都和视频里的一样,各位大佬帮我看一下为什么不会执行最后的f();方法
这个实在看不清楚,还是把代码调整一下重新上传一遍看看吧。