Bug 531

Summary: Error exists when increasing the infected location
Product: Group 15 Reporter: tcwong285-c
Component: Coronavirus TrackerAssignee: tcwong285-c
Status: CONFIRMED ---    
Severity: normal CC: aidanyip2-c
Priority: ---    
Version: 1.0   
Hardware: PC   
OS: Windows   
Attachments: This is the error message occur when I want to input the patientID

Description tcwong285-c 2020-12-07 18:32:02 HKT
When I want to increase the infected location, the following error exists and is not handled.

Enter the infected PatientID that you want to add the location visited for: 
!@#!@##!@%#@%#@$@#$#@$@#$#@@@@@@@@@@@@@@$@#$#@$@#C#CECERCE
java.lang.NumberFormatException: For input string: "!@#!@##!@%#@%#@$@#$#@$@#$#@@@@@@@@@@@@@@$@#$#@$@#C#CECERCE"
Please enter command: ["c", "sn", "sp", "i", "slv", "cs", "d", "x", "undo", "redo"]
c = create Patient, sn = show latest infection report, sp = show patient, i = increase location of infection spreading, slv = search different level of infection location, cs= change patient's health status, d = display undo/redo list, x = exit system, u = undo, r = redo

	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:638)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at InfectionTracker.Command.IncreaseLocationVisitedCommand.execute(IncreaseLocationVisitedCommand.java:36)
	at InfectionTracker.Object.Admin.showMenu(Admin.java:36)
	at InfectionTracker.Dataset.Account.showMenu(Account.java:43)
	at InfectionTracker.Main.main(Main.java:52)
Comment 1 tcwong285-c 2020-12-07 21:47:49 HKT
I have handled this exception by adding a catch block to handle the NumberFormatException. Only valid location format and PatientID will be considered as input correctly. Those symbols '!@#$@#%^' will not be taken as a normal input.
Comment 2 tcwong285-c 2020-12-07 22:33:40 HKT
Created attachment 67 [details]
This is the error message occur when I want to input the patientID