| Summary: | InteralScheduling - only return one schedule for overlap lesson | ||
|---|---|---|---|
| Product: | Group 13 | Reporter: | Tsang Yat Fung <yatftsang2-c> |
| Component: | algorithm | Assignee: | Tsang Yat Fung <yatftsang2-c> |
| Status: | CONFIRMED --- | ||
| Severity: | major | ||
| Priority: | --- | ||
| Version: | unspecified | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
Tsang Yat Fung
2018-11-25 21:53:52 HKT
Edit the function findOptimalScheule(StudentSchedule tempNewStudentSchedule,int pointer) in Class InteralScheduling. Change: StudentSchedule TempNewStudentSchedule = (StudentSchedule)tempNewStudentSchedule.clone(); --- In Line175 To: Gson gson = new Gson(); StudentSchedule TempNewStudentSchedule = gson.fromJson(gson.toJson(tempNewStudentSchedule), StudentSchedule.class); The reason of bug is because the second schedule is the shallow copy of the first schedule object. When running the function findOptimalScheule() for the second schedule, it changing the object in the first schedule rather than clone a new obj for the second schedule. Thus, a deep copy is need. We using the library of Gson to transfer the StudentSchedule obj to JSON format for easier deep copy. |