Skip to content

Commit

Permalink
Merge pull request #221 from rexkoh425/A-RexCodeQuality
Browse files Browse the repository at this point in the history
A-RexCodeQuality
  • Loading branch information
rexkoh425 authored Nov 11, 2024
2 parents 86242dc + 7d9afae commit bab215e
Show file tree
Hide file tree
Showing 21 changed files with 207 additions and 97 deletions.
84 changes: 67 additions & 17 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,75 @@ No reused/adapted ideas, code, documentation, and third-party libraries was used

## Limitations of PlantUML

1) Class is shown both at the top and bottom for sequence diagram instead of only at the top.
2) Circle with capitalised first letter is shown in class diagram beside the class name e.g. C when class is
1) Circle with capitalised first letter is shown in class diagram beside the class name e.g. C when class is
called Customer.
3) Other software might be used by the team if plantUML is unable to display what they want, explaining difference
2) Other software might be used by the team if plantUML is unable to display what they want, explaining difference
in diagrams across the team

## Design & implementation

The following is our overall class diagram for our whole project. To reduce the size of the overall diagram , only class
The following is our overall architecture diagram for our whole project. To reduce the size of the overall diagram , only class
names are included.

![Local Image](images/Overall.png)

### Sequence diagrams

1. `Adding a customer`
---
### Adding a customer

The following sequence diagram will explain the sequence of events after the user inputs an add-user command.
### Implementation:
The following sequence diagram will illustrate the sequence of events of a **valid** `add-user` operation. Customer
details like age and contact number are stored which are useful when the rental company would like to contact
the customer and creating transactions.

### Sequence diagram
![Local Image](images/AddCustomerSequence.png)

2. `Creating Car file and loading file`
### High-level steps

1) Parse the input into its parameters and extract the content.
2) Create the new Customer object if all parameters fit the format.
3) Add it to the current Customer ArrayList.

---
### Creating file and loading file at the start of the program

### Implementation:
The following sequence diagram will explain the sequence of events for loading of the carData.txt which happens at the
start of the program. The carData.txt will be created if it does not exist at the start of program and its data will be
start of the program. The operations involved for the other two files are very similar so we will use the example of
carData.txt. The carData.txt will be created if it does not exist at the start of program and its data will be
loaded if the file exist.

### Sequence diagram
![Local Image](images/CarFileLoader.png)

### High-level steps

1) File is created if it does not exist.
2) Each line in the file is scanned and checked that each parameter is correctly formatted.
3) The correct data is parsed into a new Car object.
4) Each Car object is placed into the ArrayList.

### Rationale behind way of implementation:

Similar to real-world applications, data are stored on the computer already and does not require the user to explicitly
load data from a specific location. It should be automatic and hassle-free. Preventing the corrupted data from entering
the system is also important as it might crash the program thus it is important to check the data before adding.

### Alternatives considered:
* User can choose which file to load
* Cons
1) Too complicated as there are too many possible file paths possible and would significant add to the complexity of
the program.
* User can choose whether to load data file and save when they want to.
* Pros
1) User has more control over the version control of the data files.
* Cons
1) User experience might decrease as they constantly have to save files themselves.
2) Many important data can be lost if program crashes before saving of file which does not happen with
constant updating.

---
### Auto updating of car rental status feature

### Implementation:
Expand Down Expand Up @@ -124,7 +164,7 @@ Responsibility principle (SRP) or Separation of Concerns principle (SOC).
- Cons:
- Possibility that user might forget to update rental status
- Need to add new commands to update rental status (e.g. `mark-rented`)

---
### Implementation of Transaction Completion Management and Retrieval Features

To enhance the functionality of **CliRental**, we have implemented features that allow users to mark transactions as completed or uncompleted, list transactions based on their completion status, and find transactions by customer name. These features streamline the process of managing rental transactions, ensuring accurate tracking and easy retrieval of relevant data.
Expand Down Expand Up @@ -196,7 +236,7 @@ The implementation of these features is encapsulated within the `TransactionList
- `Maintainability` : When new parameters are introduced, only 3 methods and less than 10 lines of code
needs to be updated.


---
## Product scope
### Target user profile

Expand All @@ -212,10 +252,15 @@ finding the transaction they are looking for easily with multiple filters.

## User Stories

|Version| As a ... | I want to ... | So that I can ...|
|--------|----------|---------------|------------------|
|v1.0|new user|see usage instructions|refer to them when I forget how to use the application|
|v2.0|user|find a to-do item by name|locate a to-do without having to go through the entire list|
| Version | As a ... | I want to ... | So that I can ... |
|---------|--------------------------------|--------------------------------|---------------------------------------|
| v1.0 | car rental frontdesk employee | know status of all the cars | inform customers about availability |
v1.0 | car rental frontdesk employee | add customer details to our database | keep records for future transactions |
v2.0 | car rental frontdesk employee | save all my data | ensure information will never be lost |
v2.0 | - | - | - |
v2.0 | - | - | - |
v2.0 | - | - | - |
| v2.0 | - | - | - |

## Non-Functional Requirements

Expand All @@ -237,8 +282,13 @@ transactionData.txt should be created in the data folder as well if it does not

`Test case 2` :

`details` : Adding a user using `add-user /u john /a 30 /c +65 77777777` <br>
`details` : Adding a user using `add-user /u john /a 30 /c 12345678` <br>
`check` : The command should return an error message saying that the format of contact number is wrong. Using
`+6577777777` should allow you to add the user successfully now.
`87777777` for the contact number should allow you to add the user successfully now.

`Test case 3` :

`details` : Adding a user using `add-user /u john /a 16 /c +65 77777777` <br>
`check` : The command should return an error message saying that the age is illegal to drive which is true
for most countries at age of 16. Our legal age is 18 thus changing the age to 18 and above but maximally 100 years old
will work now.
1 change: 1 addition & 0 deletions docs/UML/AddCustomerSequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ activate CustomerList
Parser <-- CustomerList : return
deactivate CustomerList
deactivate Parser
hide footbox
@enduml
2 changes: 1 addition & 1 deletion docs/UML/CLiRental.puml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class CustomerList{
printCustomers() : void
customerListToFileString() : string
}

hide footbox
@enduml
5 changes: 4 additions & 1 deletion docs/UML/CarFileLoader.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'https://plantuml.com/sequence-diagram

autonumber
participant ":CarFile" as CarFile
participant ":FileHandler" as FileHandler
participant ":CarFile" as CarFile
participant ":Scanner" as scanner
participant "errorLines \n: ArrayList<Integer>" as ArrayList
participant ":Car" as Car
Expand Down Expand Up @@ -54,6 +54,7 @@ activate CarFile
deactivate ArrayList
else
CarFile -> CarFile : addCarWithParameters(...)
opt parameters are correctly formatted
activate CarFile
CarFile -> Car : new Car()
activate Car
Expand All @@ -67,6 +68,7 @@ activate CarFile
deactivate CarList
CarList --> CarFile : return
deactivate CarList
end opt
CarFile --> CarFile : return
deactivate CarFile
end alt
Expand All @@ -87,4 +89,5 @@ deactivate CarFile

<-- FileHandler : return
deactivate FileHandler
hide footbox
@enduml
1 change: 1 addition & 0 deletions docs/UML/ListCarsSequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ alt carsList is not empty
end loop
end alt
<-- CarList : return
hide footbox
@enduml
35 changes: 20 additions & 15 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ Summary of Contents:
4. Open your terminal and navigate to the folder the jar file is placed in.
5. Run java -jar CliRental.jar and you can start using right away.

## Features

---
## File Saving
### File Saving

`Customer`, `Transaction`, and `Car` data will be saved in their respective files under the `data` directory.


### `IMPORTANT NOTE / DISCLAIMER: `
#### `IMPORTANT NOTE / DISCLAIMER: `

* The file saving feature does not include the functionality of being able to add/edit data by editing the text files.
Please add/edit data via the command line using the commands given.
Expand Down Expand Up @@ -81,7 +83,7 @@ Types :
**Example:**

* `Car data` : `Toyota Corolla | SGM4932K | 120.0 | false | false`
* `Customer data` : `John | 22 | +6590907638`
* `Customer data` : `John | 22 | 90907638`
* `Transaction data` : `TX1 | SGM4932K | John | 30 | 17-10-2024 | false`

Others :
Expand All @@ -101,10 +103,9 @@ Adds a customer to the list of customers tracked by the car rental application.
* `AGE` : `INT`
* age should be > 17 and <= 100.
* `CONTACT_NUMBER` : `STRING`
* `+[ANY NUMBER OF DIGITS]`
* `No space between + and the first digit`
* `No space between subsequent digits as well`
* `E.g. +6595382572`
* `[8 DIGITS AND STARTS WITH 8 or 9]`
* `No space between digits`
* `E.g. 95382572`
* `/u` , `/a` , `/c` must be in sequence.

**Example of usage:**
Expand All @@ -117,6 +118,7 @@ Customer added
Customer name : John
Age : 18
Contact Number : 95382572
```

### Removing a User from the Database: `remove-user`
Expand Down Expand Up @@ -165,8 +167,9 @@ If the list is **empty**:
```
list-users
Customer list is empty.
```
```
---
### Adding a Car: `add-car`

Adds a car to the car list.
Expand All @@ -191,7 +194,7 @@ Car added to list
Car details:
Honda Civic | SGE1234X | $10000.00 | Available | Affordable | Median price: 10000.0
```

---
### Removing a Car: `remove-car`

Removes a car from the fleet based on the car's unique ID.
Expand All @@ -213,7 +216,7 @@ If the `LICENSE_PLATE_NUMBER` is not found:
```
No car found with license plate [SGE1234X]
```

---
### Removing all Cars: `remove-all-cars`

Removes all cars from the fleet.
Expand Down Expand Up @@ -244,7 +247,7 @@ If the list is **empty**:
Oops!! Car list is empty...
Use command <add-car> to add a new car.
```

---
### Listing All Rented Out Cars: `list-rented`

Lists all the cars that are currently rented out.
Expand All @@ -263,7 +266,7 @@ If the list is **empty**:
```
No cars currently rented out...
```

---
### Listing All Available Cars: `list-available`

Lists all available cars in the company.
Expand All @@ -281,7 +284,7 @@ If the list is **empty**:
```
There are no available cars at the moment...
```

---
### Updating Rental Status of Car

There is no need to manually update the rental status of a car.
Expand All @@ -307,7 +310,7 @@ Transaction added:
[ ] TX2 | SZZ1579D | John | 15 days
Start Date: 11-05-2025 | End Date: 26-05-2025
```

---
### Removing a Transaction: `remove-tx`

Removes a specific rental transaction from the system based on the transaction ID.
Expand All @@ -332,6 +335,7 @@ If the `TRANSACTION_ID` is not found:
```
Transaction not found
```
---

### Removing All Transactions: `remove-all-txs`

Expand Down Expand Up @@ -364,6 +368,7 @@ If the list is **empty**:
No transaction available.
```

---
### Listing All Completed Transactions: `list-txs-completed`

Displays all transactions that are marked as completed list in this format for each transaction:
Expand Down Expand Up @@ -432,7 +437,7 @@ If the `TRANSACTION_ID` is not found:
```
Transaction not found
```

---
### Unmarking a Transaction as Incomplete: `unmark-tx`

Unmarks a rental transaction, indicating it is not yet completed.
Expand Down
Loading

0 comments on commit bab215e

Please sign in to comment.