Bug 785 - Exception throwed on main by scanner.java
Summary: Exception throwed on main by scanner.java
Status: RESOLVED FIXED
Alias: None
Product: CS3343 Group_13 Hotel Management System
Classification: Unclassified
Component: Alogrithm (show other bugs)
Version: 1.2
Hardware: PC Mac OS
: High enhancement
Assignee: NG HOI HING
URL:
Depends on:
Blocks:
 
Reported: 2023-11-23 16:52 HKT by NG HOI HING
Modified: 2023-11-23 17:02 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description NG HOI HING 2023-11-23 16:52:26 HKT
This Bug caused in main function, it will success we are choose from yes or no(y/n) in terminal, but when trying to input another alphabet, the program will throw an exception
Comment 1 NG HOI HING 2023-11-23 17:00:38 HKT
> repairRequest|10112023-12-13Initiating checking process.Checking all furniture from the room...Checkingthe floor tile...Checking all electrical appliances...Checking sanitary ware..Room 101's device situation has been thoroughly checked, and need to be
> Maintain it now?(Y/N)
9
> Wrong Input! Pease Try Again!
>YInitiating advanced repairing process.Removing all items from the room...Place a layer of dustproof paper on the walls and floors of the room...Maintenance in progress.Room 101 has been impeccably repaired.
> repairRequest]10112023-12-13Initiating checking process..Checking all furniture from the room...Checking the floor tile...Checking all electrical appliances..Checking sanitary ware..Room 101's device situation has been thoroughly checked, and need to be
> Maintain it now?(Y/N)Exception in thread "main" 


java.util.NoSuchElementExceptionat java.base/java.util.Scanner.throwFor(Scanner.java:945)
atjava.base/java.util.Scanner.next(Scanner.java:1486)
atproject.CmdRepairRequest.execute(CmdRepairRequest.java:30)atproject.Main.main(Main.java:43)


When we duplicated input the repairing request for one room, an exception will be thrown which ralated to Scanner.java, if we deleted "scanner.close()", the bug will be fixed
Comment 2 NG HOI HING 2023-11-23 17:02:05 HKT
For update, the wrong input will be ok, only the problem of the scanner.close(),
The bug is fixed since we remove the scanner.close()