Recommend command array out of bounds. When there are less than 2 events that are the same major or less than 2 events are not the same major with the target recommend student, it will have an error of array out of bounds. ============================================================================ Welcome to the Event Management System Please input today date (e.g. 01-jan-2020). 13-oct-2020 SystemDate confirm: 13-Oct-2020 Please enter your command: create event badminton e12345678 10 20-oct-2020 cs 5 2 3 Created badminton event with EventID: e12345678. Please enter your command: create student s12345678 cs mary chan F 19 Created student mary chan with StudentID: s12345678. Please enter your command: recommend s12345678 Here are the recommended events from your department: |Event ID |Event Name |Date |Capacity|Major |Quota|Type |Group Capacity |Group Quota|Min No. In Group|Max No. In Group| |e12345678 |badminton |20-Oct-2020 |10 |Computer Science |10 |Group |5 |5 |2 |3 | Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at EventManagementSystem.CmdRecommend.execute(CmdRecommend.java:57) at EventManagementSystem.Main.main(Main.java:128) ============================================================================
Added a counter value to make sure the loop will not loop over the array bounds.