nus-cs2103-AY2021S2 / pe-dev-response

0 stars 0 forks source link

Inconsistency in invalid index number messages #3128

Open nus-pe-bot opened 3 years ago

nus-pe-bot commented 3 years ago

The following three screenshots are invalid index numbers for the delete_tutor command. This fits the other commands as well, but I regard it as the same bug.

When the index is ≤0 or >INT_MAX, it shows one type of error message, but shows other type is the index is >0 and ≤INT_MAX but not on the list.

image.png

image.png

image.png


[original: nus-cs2103-AY2021S2/pe-interim#3128] [original labels: severity.Low type.FunctionalityBug]

Winniehyx commented 3 years ago

Team's Response

Dear responder, thank you for highlighting this issue.

Our application made use of built-in Java methods to attempt to parse the index (given as String) to an integer as referenced from: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Integer.html#parseInt(java.lang.String)

Step 1: This method checks if the integer is unsigned non-zero. Step 2: If the integer entered is a very large positive integer that resulted in overflows, step 1 will fail, which is a limitation of Java itself. Hence, 16767686129031 is deemed not to be a valid integer.

To further address about index 0, as referenced from math.com, an integer is a whole number that can be either greater than 0, called positive, or less than 0, called negative. Zero is neither positive nor negative. Hence, the error message output from entering index 0 is accurate.

Furthermore, there were no undesirable behaviours or unhandled exceptions produced from typing index such as 0 or 16767686129031 from what you have demonstrated.

Duplicate status (if any):

--