我正在编写代码以生成本学期所有可能的时间表。我想在课程注册之前查看所有时间表选项。
public static ArrayList<Schedule> findAllSchedules(ArrayList<ArrayList<Course>> courses, int courseAmount, boolean[][] isVisited)
{
ArrayList<Schedule> all = new ArrayList<Schedule>();
Schedule temp = new Schedule();
for(int i = 0; i < courses.size(); i++)
{
ArrayList<Course> row = courses.get(i);
for(int col = 0; col < row.size(); col++)
{
if(temp.isFit(row.get(col)))
{
if(!isVisited[i][col])
{
temp.add(row.get(col));
if(courseAmount == temp.courses)
{
isVisited[i][col] = true;
all.add(temp);
temp.writeSchedule();
all.addAll(findAllSchedules(courses,courseAmount,isVisited));
isVisited[i][col] = false;
}
}
}
}
}
}
我希望所有选项都可以,但是这只是更改arraylist的最后一部分。
我想这足够了,但是如果有任何不清楚的表达,请问我。