Skip to content

Commit

Permalink
Merge pull request #173 from JeffinsonDarmawan/table-format
Browse files Browse the repository at this point in the history
Table format
  • Loading branch information
samuelory committed Apr 15, 2024
2 parents 37be645 + 6a7deff commit f21a2a0
Show file tree
Hide file tree
Showing 15 changed files with 720 additions and 273 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repositories {
dependencies {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.0'
implementation('com.github.freva:ascii-table:1.8.0')
}

test {
Expand Down Expand Up @@ -43,5 +44,5 @@ checkstyle {

run{
standardInput = System.in
enableAssertions = true;
enableAssertions = true
}
225 changes: 141 additions & 84 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,44 @@ Format: `help`
Expected output:

```
Here are the list of commands you can use:
1. new <bouquetName> - Add a bouquet
2. delete <bouquetName> - Delete a bouquets
3. mybouquets - List current saved bouquets
4. info <flowerName> - Provide information on chosen flower
5. add <flowerName> /q <quantity> /to <bouquetName> - add flower to a bouquet
6. remove <flowerName> /q <quantity> /from <bouquetName> - remove flower from a bouquet
7. flowers - Shows a list of flowers that can be added into mybouquets
8. flowers <occasion> - Shows a list of flowers associated with said occasion
9. occasion - Shows a list of occasions associated with available flowers
10. save <bouquetName> - Saves a bouquet to an external <bouquetName>.txt file
11. recommend - Recommends a bouquet based on the chosen occasion and colour
12. bye - Exits the programme
Here is the table showing a list of commands you can use:
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| No. | Command | Explanation | Example |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 1 | new <bouquetName> | Add a bouquet | new Birthday Bouquet |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 2 | delete <bouquetName> | Delete a bouquets | delete Birthday Bouquet |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 3 | mybouquets | List current saved bouquets | mybouquets |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 4 | info <flowerName> | Provide information on chosen flower | info Rose |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 5 | add <flowerName> /c <colour> (optional) /q <quantity> | Add flower to a bouquet | add Rose /c Red /q 5 /to Birthday Bouquet |
| | /to <bouquetName> | | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 6 | remove <flowerName> /c <colour> (optional) /q <quantity> | Remove flower from a bouquet | remove Rose /c Red /q 5 /from Birthday Bouquet |
| | /from <bouquetName> | | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 7 | flowers | Shows a list of flowers that can be | flowers |
| | | added into mybouquets | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 8 | flowers <occasion> | Shows a list of flowers associated | flowers Valentines |
| | | with said occasion | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 9 | occasion | Shows a list of occasions associated | occasion |
| | | with available flowers | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 10 | save <bouquetName> | Saves a bouquet to an external | save Birthday Bouquet |
| | | <bouquetName>.txt file | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 11 | recommend | Recommends a bouquet based on the | recommend |
| | | chosen occasion and colour | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 12 | compare <1st flowerName> /vs/ <2nd flowerName> | Show information regarding two flowers | compare Rose /vs/ Lily |
| | | side-by-side for comparison | |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
| 13 | bye | Exits the programme | bye |
+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+
```

### Create a new bouquet: `new`
Expand Down Expand Up @@ -118,12 +143,14 @@ Example: `info Lily`

Expected Output:
```
Here is page 1/1 of info regarding flowers whose name contains Lily:
1. Name: Lily
Colour: White
Occasions: Funeral, Wedding
Price: $2.50
Meanings: Innocence
Here is a table of information about the flower Lily:
+-----+-------------+--------+--------------------+-------------+--------+-----------+
| No. | Flower Name | Colour | Occasion | Meaning | Type | Price ($) |
+-----+-------------+--------+--------------------+-------------+--------+-----------+
| 1 | Lily | White | [FUNERAL, WEDDING] | [Innocence] | FLOWER | 2.50 |
+-----+-------------+--------+--------------------+-------------+--------+-----------+
| 2 | Lily | Orange | [] | [Hatred] | FLOWER | 2.50 |
+-----+-------------+--------+--------------------+-------------+--------+-----------+
____________________________________________________________
```

Expand Down Expand Up @@ -199,46 +226,46 @@ Recommends a bouquet based on the occasion and the recipient's preference
Steps:
1. Type command: `recommend`

Expected output:
```
For what occasion are you buying flowers for?
Here is the list of our available occasion:
Here are all the occasions associated with the available flowers:
- Funeral
- Wedding
- Valentines
- Mothers day
____________________________________________________________
```
Expected output:
```
For what occasion are you buying flowers for?
Here is the list of our available occasion:
Here are all the occasions associated with the available flowers:
- Funeral
- Wedding
- Valentines
- Mothers day
____________________________________________________________
```
2. Type occasion: `Funeral`

Expected output:
```
What colour would you like your bouquets to be?
Here is the list of colours available for the occasion:
- DARK_CRIMSON
- WHITE
```
Expected output:
```
What colour would you like your bouquets to be?
Here is the list of colours available for the occasion:
- DARK_CRIMSON
- WHITE
```

3. Select colour of bouquet: `WHITE`

Expected output:

```
Would you like to save this bouquet to your list?
Here is the full list of flowers in Recommended Bouquet:
- 3 x Lily
- 2 x Chrysanthemum
____________________________________________________________
Type 'yes' to save, 'no' to discard
```
Expected output:
```
Would you like to save this bouquet to your list?
Here is the full list of flowers in Recommended Bouquet:
- 3 x Lily
- 2 x Chrysanthemum
____________________________________________________________
Type 'yes' to save, 'no' to discard
```
4. Confirm whether you want to add the recommended bouquet to your mybouquets list: `yes`

```
Added new bouquet to list:
Recommended Bouquet
____________________________________________________________
```
```
Added new bouquet to list:
Recommended Bouquet
____________________________________________________________
```

### Save a bouquet to device: `save`
Saves chosen bouquet, if it exists, locally to the users device
Expand All @@ -255,6 +282,34 @@ Expected Output:
Successfully saved moms bouquet. You can find it at 'florizz-out/saved/moms bouquet.txt'
```

### Compare two flowers: `compare`
Compares the colour, occasion, meaning, type and price of flowers based on flower names

Format: `compare <flowerName1> /vs/ <flowerName2>`

- Both flowers must exist in the database

Examples:
- `compare Rose /vs/ Lily`

Expected output:
```
Here is a table of comparison between the two flowers:
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
| No. | Flower Name | Colour | Occasion | Meaning | Type | Price ($) |
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
| 1 | Rose | Dark crimson | [FUNERAL] | [Mourning] | FLOWER | 2.00 |
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
| 2 | Rose | Red | [VALENTINES, WEDDING, MOTHERS_DAY] | [Love] | FLOWER | 2.00 |
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
| 3 | Rose | Yellow | [] | [Jealousy, Decrease of love, Infidelity] | FLOWER | 2.00 |
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
| 4 | Lily | White | [FUNERAL, WEDDING] | [Innocence] | FLOWER | 2.50 |
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
| 5 | Lily | Orange | [] | [Hatred] | FLOWER | 2.50 |
+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+
```

### Exit programme: `bye`

Exits the program.
Expand All @@ -268,50 +323,52 @@ Enjoy your bouquet! Thank you for using Florizz!

### Fuzzy Logic

Florizz uses a type of fuzzy logic to rectifies typos in user input by utilising the Damerau-Levenshtein Distance
to measure the similarity between the user input and a valid command/item/occasion.
Florizz uses a type of fuzzy logic that rectifies typos in user input by utilising the Damerau-Levenshtein Distance
to measure the similarity between the user input and a valid command/flower/colour/occasion.

The Damerau-Levenshtein distance measures the minimum number of single-character edits required to change one string
into another. These edits can be insertions, deletions, substitutions and transpositions of individual characters.

When a typo is detected, Florizz will make a calculated guess as to the valid commands that a user is actually calling.
When a typo is detected, Florizz will make a calculated guess as to the valid command that a user is actually referring to.

Examples:
- `newq mybouquet1`
- `adds Chysanthenum /q 10 /to mybouquet1`
- `delate mybouquet1`
Examples of typos that Florizz can rectify include:

1. Typo in spelling
- `flowerz Vlentine`
- `ads Ross /c ret /q 10 /to mybouquet1`
2. Incorrect placements of whitespaces
- `c o m p are R ose /v s/ L i ly`
- `m y b ouq ue ts`
3. Absence of whitespaces
- `flowersmothersday`
- `infoDaisy`

Note: Fuzzy Logic only works for commands, flower names, colours and occasions, and it cannot rectify typos which
combine no. 1 with no. 2 or no. 3.

Expected output:

```
newq mybouquet1
--> Your input is [newq] but I am guessing you mean [new]
Added new bouquet to list:
mybouquet1
____________________________________________________________
What can I do for you?
flowerz Vlentine
--> Your input is [flowerz] but I am guessing you mean [flowers]
--> Your input is [Vlentine] but I am guessing you mean [Valentines]
```

```
adds Chysanthenum /q 10 /to mybouquet1
--> Your input is [adds] but I am guessing you mean [add]
--> Your input is [Chysanthenum] but I am guessing you mean [Chrysanthemum]
You have successfully added the following:
- 10 x chrysanthemum -> Bouquet: mybouquet1
Here is the list of your saved bouquets:
1. mybouquet1 :
- 10 x Chrysanthemum
Total estimated price = $10.00
____________________________________________________________
What can I do for you?
ads Ross /c ret /q 10 /to mybouquet1
--> Your input is [ads] but I am guessing you mean [add]
--> Your input is [Ross] but I am guessing you mean [Rose]
--> Your input is [ret] but I am guessing you mean [Red]
```

```
delate mybouquet1
--> Your input is [delate] but I am guessing you mean [delete]
Deleted bouquet:
mybouquet1
____________________________________________________________
What can I do for you?
c o m p are R ose /v s/ L i ly
--> Your input is [c o m p are R ose /v s/ L i ly] but I am guessing you mean [compare Rose /vs/ Lily]
```

```
flowersmothersday
--> Your input is [flowersmothersday] but I am guessing you mean [flowers Mothers Day]
```

### Autosave
Expand Down
Loading

0 comments on commit f21a2a0

Please sign in to comment.