Bug 772 - This bug has caused the data structure of the hash table to be unable to find or allocate the correct key values
Summary: This bug has caused the data structure of the hash table to be unable to find...
Status: RESOLVED FIXED
Alias: None
Product: CS3343 Group_13 Hotel Management System
Classification: Unclassified
Component: Alogrithm (show other bugs)
Version: 1.2
Hardware: PC Windows
: Highest enhancement
Assignee: NG HOI HING
URL:
Depends on:
Blocks:
 
Reported: 2023-11-08 23:01 HKT by NG HOI HING
Modified: 2023-11-23 16:37 HKT (History)
1 user (show)

See Also:


Attachments
Location: CmdCheckin.java (127.43 KB, patch)
2023-11-23 11:44 HKT, NG HOI HING
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description NG HOI HING 2023-11-08 23:01:51 HKT
Unable to insert values correctly into the hash table
Comment 1 NG HOI HING 2023-11-23 11:41:46 HKT
During the programming process, we encountered an issue with data structures. We planned to approach it using a four-dimensional space analogy based on a real-life hotel example. Our intention was to use a hash table to store time intervals. However, we discovered that this approach was not effective. Storing time intervals in the hash table had the possibility of being overwritten by updated time intervals. As a result, there could be variations in the outcomes when running the program on different compilers or hosts.
Comment 2 NG HOI HING 2023-11-23 11:44:03 HKT
Created attachment 151 [details]
Location: CmdCheckin.java

Please follow the aforementioned path to find the problem
Comment 3 NG HOI HING 2023-11-23 11:46:25 HKT
The bug has been fixed, we kept the data structure in hash map, but we store the time point rather than period, the program will be normally run
Comment 4 NG HOI HING 2023-11-23 16:37:24 HKT
Test Code:

For initializing:
addRoom|101|Queen
addRoom|102|Deluxe
addRoom|103|Double
addRoom|104|Queen
addRoom|105|Deluxe
addRoom|106|Double
addRoom|107|Queen
addRoom|108|Deluxe
addRoom|109|Double
addRoom|110|Queen
addRoom|111|Deluxe
addRoom|112|Double

*The Room Addition will firstly set the 'Dirty' and 'Harmed' status for all room 

Check Rooms' Status:
listRooms|2023-12-13

The output is:
Room Number: 101 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 102 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 103 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 104 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 105 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 106 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 107 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 108 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 109 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 110 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 111 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 112 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed


If we run the 'cleanResponse' (purpose:set rooms' status to 'Clean')

Expected Output:




Actual Output:
Room Number: 101 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 102 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Clean | Device Status: Harmed
Room Number: 103 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 104 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 105 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 106 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 107 | Room Type: Queen | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 108 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Clean | Device Status: Harmed
Room Number: 109 | Room Type: Double | Room Status: Available | Hygiene Status: Clean | Device Status: Harmed
Room Number: 110 | Room Type: Queen | Room Status: Available | Hygiene Status: Clean | Device Status: Harmed
Room Number: 111 | Room Type: Deluxe | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed
Room Number: 112 | Room Type: Double | Room Status: Available | Hygiene Status: Dirty | Device Status: Harmed


It should be noticed that some rooms' status are not been set to Clean though we execute the cleanResponses.
Also, when we execute in different machine\software, the output may also be different.