Skip to content

Commit

Permalink
Merge pull request #231 from SemiColonKen/master
Browse files Browse the repository at this point in the history
Update UG to be more detailed. Added junittest for remove-user. Updated remove-user for empty customer list. Added PPP
  • Loading branch information
tkhahns authored Nov 12, 2024
2 parents f0676fb + fdd8101 commit 72f5de6
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 10 deletions.
23 changes: 21 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ Removes a customer from the customer list.
**Format:** `remove-user /u [CUSTOMER_NAME]`

* `CUSTOMER_NAME` : `STRING`.
* `CUSTOMER_NAME` must match an existing customer in the database.
* `CUSTOMER_NAME` is not case sensitive. 'John' and 'john' mean the same customer.

**Example of usage:**
`remove-user /u John`

**Sample Response:**
```
User John has been removed
John has been removed from customer list
```
### Removing all Users from the Database: `remove-all-users`

Expand Down Expand Up @@ -200,7 +202,7 @@ Removes a car from the fleet based on the car's unique ID.

**Format:** `remove-car /i [LICENSE_PLATE_NUMBER]`

- `/i` identifier specifies the car ID to be removed.
- `/i` identifier specifies the license plate number belonging to the car that is to be removed.
- `LICENSE_PLATE_NUMBER` must match an existing car in the database.

**Example:**
Expand Down Expand Up @@ -300,8 +302,25 @@ The status will be updated automatically when a transaction record is:

Adds a new rental transaction to the system.

To add transaction bearing either an existing license plate number and/or customer name, all previous transactions containing either both or one of the parameter must be either marked as completed or be removed from the transaction list.

**Format:** `add-tx /c [LICENSE_PLATE_NUMBER] /u [CUSTOMER_NAME] /d [DURATION] /s [START_DATE: dd-MM-yyyy]`

- `/c` identifier specifies the license plate number of the car the customer wants to rent.
- `LICENSE_PLATE_NUMBER` must match an existing car in the database. This is unique as the program will not allow 2 cars to have the same license plate number.


- `/u` identifier specifies the name of the customer.
- `CUSTOMER_NAME` must match an existing customer in the database. This is unique as the program will not allow 2 customers to have the same name.


- `/d` identifier specifies the duration of the rental in days.
- `DURATION` must be an integer between 1 to 365 (inclusive). This allows the rental companies to handle rental transactions from 1 day to 365 days (a year).


- `/s` identifier specifies the start date of the rental.
- `START_DATE` is in the format of [dd-MM-yyyy], accepting integers input only. It must be a valid date in the calender.

**Example:**
`add-tx /c SZZ1579D /u John /d 15 /s 11-05-2025`

Expand Down
44 changes: 44 additions & 0 deletions docs/team/SemiColonKen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Kenneth Tan - Project Portfolio Page

## Project: CliRental

CliRental is a straightforward, user-friendly application designed to help manage car rental operations efficiently.
Built with Java, this app allows users to track rental transactions, manage customer information,
and monitor car availability through a series of command-line commands. Key functionalities include
adding and removing customers, logging rental transactions, checking car availability,
and marking transactions as completed. Designed for quick access and ease of use,
this app is ideal for small to mid-sized rental services looking to streamline operations without a complex interface.

## Summary of Contributions

### <u>Features added</u>

`Feature 1` : Add the ability to remove customers details from the database.

* What it does : Allows user to remove a customer from our database.
* Justification: Customer details such as contact number can change, removal of customers allow the updated information
to be added afterwards. It also important to allow removal when details have been entered wrongly.
* Highlights: This command allows user to remove customer which is the building blocks for our application. Without the
ability to remove customers , the app would not achieve its intended use.

`Feature 2` : Add the ability add a rental transaction into the database

* What it does : Allows user to add a rental transaction into the database using information from the car and the customer
* Justification: To allow management of rental transaction, it is essential to add a rental transaction into the database.
This allows the user to keep a record of all rental transactions that have occurred which can then be view later on.
* Highlights: This command allows user to add a rental transaction which is the part of the main feature for our
application, rental management Without the ability to add transaction, the app would not serve its purpose.


### <u>Enhancements to existing features:</u>
* Worked with rexkoh425 to save Transaction ID
* Added case insensitive features for some commands, e.g remove-user and add-tx

### <u>Documentation:</u>
#### User Guide:
Added documentation for the features e.g. remove-user and list completed transactions.
Added sample outputs to match the latest release

### <u>Code Contribution</u>

Code contributed: https://nus-cs2113-ay2425s1.github.io/tp-dashboard/?search=SemiColonKen&breakdown=true
26 changes: 20 additions & 6 deletions src/main/java/customer/CustomerList.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,32 @@ public static void addCustomerWithoutPrintingInfo(Customer customer) {

customers.add(customer);
}

public static void removeCustomer(String customerName) {
for (Customer customer : customers) {
if (customers.isEmpty()) {
System.out.println("Customer list is empty. Nothing to remove");
return;
}

boolean customerFound = false;

for (int i = 0; i < customers.size(); i++) {
Customer customer = customers.get(i);
if (customer.getCustomerName().equalsIgnoreCase(customerName)) {
customers.remove(customer);
System.out.println("User " + customer.getCustomerName() + " has been removed");
return;
customers.remove(i);
System.out.println("Customer Name: " + customer.getCustomerName()
+ " has been removed from the customer list");
customerFound = true;
break;
}
}
System.out.println(customerName + " is not in the customer list. No removal done");

if (!customerFound) {
System.out.println(customerName + " is not in the customer list. No removal done");
}
}


public static void clearCustomerList() {
customers.clear();
}
Expand Down
53 changes: 51 additions & 2 deletions src/test/java/customer/CustomerListTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package customer;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import exceptions.CustomerException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class CustomerListTest {

@BeforeEach
Expand Down Expand Up @@ -101,4 +104,50 @@ public void testAddCustomerWithValidName() {
assertEquals(1, CustomerList.getCustomers().size());
assertEquals("John Doe", CustomerList.getCustomers().get(0).getCustomerName());
}

@Test
public void testRemoveCustomer_existingCustomer() {
Customer customer = new Customer("John Doe", 30, "91234567");
CustomerList.addCustomerWithoutPrintingInfo(customer);

CustomerList.removeCustomer("John Doe");

int customerListLength = CustomerList.getCustomers().size();
assertFalse(CustomerList.isExistingCustomer("John Doe"));
assertEquals(0, customerListLength, "Customer list should be empty after removal.");
}

@Test
public void testRemoveCustomer_nonExistingCustomer() {
Customer customer = new Customer("Jane Doe", 28, "81234567");
CustomerList.addCustomerWithoutPrintingInfo(customer);

CustomerList.removeCustomer("John Smith");

int customerListLength = CustomerList.getCustomers().size();
assertTrue(CustomerList.isExistingCustomer("Jane Doe"));
assertFalse(CustomerList.isExistingCustomer("John Smith"));
assertEquals(1, customerListLength, "Customer list should contain 1 customer after non-existent removal.");
}

@Test
public void testRemoveCustomer_caseInsensitive() {
Customer customer = new Customer("Alice Smith", 35, "91234567");
CustomerList.addCustomerWithoutPrintingInfo(customer);

CustomerList.removeCustomer("alice smith");

int customerListLength = CustomerList.getCustomers().size();
assertFalse(CustomerList.isExistingCustomer("Alice Smith"));
assertEquals(0, customerListLength, "Customer list should be empty after removal.");
}



@Test
public void testRemoveCustomer_emptyList() {
CustomerList.removeCustomer("Non Existent Customer");
int customerListLength = CustomerList.getCustomers().size();
assertEquals(0, customerListLength, "Customer list should remain empty when there is no customer.");
}
}

0 comments on commit 72f5de6

Please sign in to comment.