Bug 494

Summary: Duplicate member registration problem with same customer ID on MacOS and Windows 10
Product: Group 4 Reporter: kykao2-c
Component: MainAssignee: Paton <plchan83-c>
Status: CONFIRMED ---    
Severity: major CC: aaronlii2-c, chlam286-c, kykao2-c, sharitsang97
Priority: High    
Version: unspecified   
Hardware: All   
OS: All   
Deadline: 2020-11-05   
Attachments: Duplicate member registration with same customer ID

Description kykao2-c 2020-11-28 14:00:13 HKT
Created attachment 58 [details]
Duplicate member registration with same customer ID

The program is able to register customers as members repeatedly. That is, the
program accepts duplicate customer ID that already exists in the database. This
problem causes tremendous impact on purchase that it affects the customers'
accumulative balance to be added inappropriately and thus, the membership may be upgraded incorrectly. 

This bug has been tested on both MacOS and Windows OS, and this bug always
occurs without any exception. The specification of the devices is as follows:
MacOS: Mojave version 10.14.6 [Device: Macbook Pro 2017, 13-inch]
Windows: Windows 10 version 20H2 build number 10.0.19042 [Device: HP Spectre
x360 13]

Severity: Major.

Step to reproduce the bug:
input:   1. "regMember ShariTsang CID_0"
result:     "Customer ShariTsang (Member ID: CID_0) has been added."

input:   2. "regMember PatonChan CID_0"
result:     "Customer PatonChan (Member ID: CID_0) has been added."

input:   3. "addProduct 1 apple 10 5"
result:     "Product apple (PID: 1) has been added."

input:   4. "regStaff Kao SID_0"
result:     "Staff Kao (Staff ID: SID_0) has been added."

input:   5. "makePurchase SID_0 CID_0 1 2"
result:     "Transaction (00000000) made."

input:   6. "listMember"
result:
           Name    Customer ID     Membership     Accumulated Expenses
     ShariTsang          CID_0         Normal                     19.4
      PatonChan          CID_0         Normal                      0.0

Example Explanation:
The bug above demonstrates the accumulated expenses are updated incorrectly to ShariTsang (CID_0) when the purchase is made by PatonChan (CID_0). 

Expectation:
The bug above should add the expenses $19.4 from Transaction (00000000) to the customer PatonChan as he made the purchase. 

Therefore, the expectation for the program is that the program should not accept customer ID to be reused. Customer ID must be
unique for each member. However, the name of customers do not require to be
unique.

Expected input (shown in "") and output:
input:   1. "regMember ShariTsang CID_0"
output:     "Customer ShariTsang (Member ID: CID_0) has been added.

input:   2. "regMember PatonChan CID_0"
output:     "Error: Member ID is taken."

By distinguishing the customer ID, the program should be able to add the accumulated expenses to the corresponding customer through a unique customer ID. As a result, in step 2, the output should be an error message instead.

Observation:
The program has not added a checking mechanism for declining all registration
requests with existing customer ID in CmdRegMember.execute(String[] cmd);

Solution:
Add a checking statement for customer ID. If the customer ID already exists, do
not register the member. Else, register.

A sample code snippet for checking duplicate customer ID is as follows:
if (customerDatabase.searchCustomer(customerID) == null) {
      //do registration
} else {
      //error message
}

Please fix this as soon as possible for enhancing the program correctness and
usability.