Bug 618 - Out-of-range input makes the program crash.
Summary: Out-of-range input makes the program crash.
Status: CONFIRMED
Alias: None
Product: CS3343 Chinese Checker
Classification: Unclassified
Component: Algorithm Component (show other bugs)
Version: unspecified
Hardware: All All
: --- minor
Assignee: yutongmen2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-29 11:53 HKT by yutongmen2-c
Modified: 2021-11-29 11:54 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yutongmen2-c 2021-11-29 11:53:35 HKT
Short description:

In the gameStream, Test the input of user, but when input (0,9) (not in (8,8) range) the program will crash.



Steps To Reproduce:

Add judge of the range to the input while loop



Actual Output:

Input Error



Expected Output:

Not valid input, please input again.
Comment 1 yutongmen2-c 2021-11-29 11:54:03 HKT
Previous code:

	do {

                if (in.hasNextInt()) {

                    start_x = in.nextInt();

                    start_y = in.nextInt();

                }

            } while (!start_m.isValidStartMove());



Modified code:

            do {

                if (in.hasNextInt()) {

                    start_x = in.nextInt();

                    start_y = in.nextInt();

                }

            } while (start_x < 0 || start_x > 8 || start_y < 0 || start_y > 8);