Bug 400 - Incorrect return cause by array out of bounds
Summary: Incorrect return cause by array out of bounds
Status: CONFIRMED
Alias: None
Product: Event Management System
Classification: Unclassified
Component: Backend (show other bugs)
Version: 1
Hardware: PC Windows
: --- enhancement
Assignee: mankitse3-c
URL:
Depends on:
Blocks:
 
Reported: 2020-11-11 00:16 HKT by mankitse3-c
Modified: 2020-11-11 00:18 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mankitse3-c 2020-11-11 00:16:51 HKT
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)
============================================================================
Comment 1 mankitse3-c 2020-11-11 00:18:36 HKT
Added a counter value to make sure the loop will not loop over the array bounds.