Bug 618

Summary: Out-of-range input makes the program crash.
Product: CS3343 Chinese Checker Reporter: yutongmen2-c
Component: Algorithm ComponentAssignee: yutongmen2-c
Status: CONFIRMED ---    
Severity: minor CC: yutongmen2-c
Priority: ---    
Version: unspecified   
Hardware: All   
OS: All   

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);