Bug 397

Summary: Invalid input of letter will not be checked
Product: Group37 Reporter: PAN Zhenyuan <pzyhihihi>
Component: calculation operationAssignee: feiwu25-c
Status: RESOLVED FIXED    
Severity: enhancement CC: danielsuendaniel, tommyhonym
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Windows   

Description PAN Zhenyuan 2020-11-07 19:30:27 HKT
Overview:
Invalid input of letter will not be checked

Step to reproduce:
1) Start the calculator
2) Enter a
3) Press Enter

Expected Result:
error message of invalid input.

Actual Result:
no response


Build Date & Hardware:
07-11-2020 on Window 10.0.18363
Comment 1 danielsuendaniel 2020-11-08 17:27:44 HKT
problem is using "while(!sc.hasNextInt())". It ignore all character and noway to show the problem input to user.

solution is edit the code from:
while (!sc.hasNextInt())
	sc.next();
int input = sc.nextInt();
sc.nextLine();
return input;


to:
String input = sc.nextLine();
try {
	int option = Integer.parseInt(input);
	return option;
} catch (NumberFormatException e) {
        throw new InvaildInputOptionException(String.valueOf(input));
}