From 3e1def7364d9480b5c2481cc2b994b4edc9ca45b Mon Sep 17 00:00:00 2001 From: samuelory Date: Mon, 15 Apr 2024 19:03:29 +0800 Subject: [PATCH] Adjusted max width of help table and updated userguide expected outputs --- docs/UserGuide.md | 97 ++++++++++++------------------ src/main/java/florizz/core/Ui.java | 9 +-- 2 files changed, 45 insertions(+), 61 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index a92a164c0e..aa67d0330d 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -12,43 +12,31 @@ Expected output: ``` Here is the table showing a list of commands you can use: -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| No. | Command | Explanation | Example | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 1 | new | Add a bouquet | new Birthday Bouquet | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 2 | delete | Delete a bouquets | delete Birthday Bouquet | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 3 | mybouquets | List current saved bouquets | mybouquets | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 4 | info | Provide information on chosen flower | info Rose | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 5 | add /c (optional) /q | Add flower to a bouquet | add Rose /c Red /q 5 /to Birthday Bouquet | -| | /to | | | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 6 | remove /c (optional) /q | Remove flower from a bouquet | remove Rose /c Red /q 5 /from Birthday Bouquet | -| | /from | | | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 7 | flowers | Shows a list of flowers that can be | flowers | -| | | added into mybouquets | | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ -| 8 | flowers | 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 | Saves a bouquet to an external | save Birthday Bouquet | -| | | .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 | -+-----+----------------------------------------------------------+----------------------------------------+------------------------------------------------+ ++-----+------------------------------------------------+----------------------------------------+------------------------------+ +| No. | Command | Explanation | Example | ++-----+------------------------------------------------+----------------------------------------+------------------------------+ +| 1 | new | Add a bouquet | new Birthday Bouquet | +| 2 | delete | Delete a bouquets | delete Birthday Bouquet | +| 3 | mybouquets | List current saved bouquets | mybouquets | +| 4 | info | Provide information on chosen flower | info Rose | +| 5 | add /c (optional) /q | Add flower to a bouquet | add Rose /c Red /q 5 /to | +| | /to | | Birthday Bouquet | +| 6 | remove /c (optional) /q | Remove flower from a bouquet | remove Rose /c Red /q 5 | +| | /from | | /from Birthday Bouquet | +| 7 | flowers | Shows a list of flowers that can be | flowers | +| | | added into mybouquets | | +| 8 | flowers | 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 | Saves a bouquet to an external | save Birthday Bouquet | +| | | .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` @@ -144,13 +132,12 @@ Example: `info Lily` Expected Output: ``` 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 | -+-----+-------------+--------+--------------------+-------------+--------+-----------+ ++-----+-------------+--------+------------------+-----------+-------------+-----------+ +| No. | Flower Name | Colour | Occasion | Meaning | Type | Price ($) | ++-----+-------------+--------+------------------+-----------+-------------+-----------+ +| 1 | Lily | White | Funeral, Wedding | Innocence | MAIN_FLOWER | 2.50 | +| 2 | Lily | Orange | - | Hatred | MAIN_FLOWER | 2.50 | ++-----+-------------+--------+------------------+-----------+-------------+-----------+ ____________________________________________________________ ``` @@ -295,19 +282,15 @@ Examples: 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 | -+-----+-------------+--------------+------------------------------------+------------------------------------------+--------+-----------+ ++-----+-------------+--------------+----------------------------------+----------------------------------------+-------------+-----------+ +| No. | Flower Name | Colour | Occasion | Meaning | Type | Price ($) | ++-----+-------------+--------------+----------------------------------+----------------------------------------+-------------+-----------+ +| 1 | Rose | Dark crimson | Funeral | Mourning | MAIN_FLOWER | 2.00 | +| 2 | Rose | Red | Valentines, Wedding, Mothers day | Love | MAIN_FLOWER | 2.00 | +| 3 | Rose | Yellow | - | Jealousy, Decrease of love, Infidelity | MAIN_FLOWER | 2.00 | +| 4 | Lily | White | Funeral, Wedding | Innocence | MAIN_FLOWER | 2.50 | +| 5 | Lily | Orange | - | Hatred | MAIN_FLOWER | 2.50 | ++-----+-------------+--------------+----------------------------------+----------------------------------------+-------------+-----------+ ``` ### Exit programme: `bye` diff --git a/src/main/java/florizz/core/Ui.java b/src/main/java/florizz/core/Ui.java index 3bf42df4d2..a58727ffa3 100644 --- a/src/main/java/florizz/core/Ui.java +++ b/src/main/java/florizz/core/Ui.java @@ -3,6 +3,7 @@ import com.github.freva.asciitable.AsciiTable; import com.github.freva.asciitable.Column; import com.github.freva.asciitable.HorizontalAlign; +import com.github.freva.asciitable.OverflowBehaviour; import florizz.objects.Bouquet; import florizz.objects.Flower; import florizz.objects.TableData; @@ -172,13 +173,13 @@ public void printHelpMessage() { , "bye") ); System.out.println(AsciiTable.getTable(AsciiTable.BASIC_ASCII_NO_DATA_SEPARATORS, tableData, Arrays.asList( - new Column().header("No.").dataAlign(HorizontalAlign.CENTER) + new Column().header("No.").dataAlign(HorizontalAlign.CENTER).maxWidth(5, OverflowBehaviour.NEWLINE) .with((TableData data) -> Integer.toString(data.getId())), - new Column().header("Command").dataAlign(HorizontalAlign.LEFT) + new Column().header("Command").dataAlign(HorizontalAlign.LEFT).maxWidth(48, OverflowBehaviour.NEWLINE) .with(TableData::getCommand), - new Column().header("Explanation").dataAlign(HorizontalAlign.LEFT) + new Column().header("Explanation").dataAlign(HorizontalAlign.LEFT).maxWidth(40, OverflowBehaviour.NEWLINE) .with(TableData::getExplanation), - new Column().header("Example").dataAlign(HorizontalAlign.LEFT) + new Column().header("Example").dataAlign(HorizontalAlign.LEFT).maxWidth(30, OverflowBehaviour.NEWLINE) .with(TableData::getExample)))); printBreakLine(); }