Skip to content

Commit

Permalink
Merge pull request #257 from XavierLiau34/master
Browse files Browse the repository at this point in the history
Added Quote Command
  • Loading branch information
YHWong20 authored Apr 15, 2024
2 parents ec1f487 + b05ded3 commit 6b16d6b
Show file tree
Hide file tree
Showing 25 changed files with 753 additions and 43 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ for your daily operations.

<img src="docs/images/Ui_1.png" alt="BinBash Intro" width="800"/>


## Features
- **Stock Management**: Keep track of what's in stock, with the ability to add, update, sell, restock and delete easily.
- **Inventory viewing**: View your inventory with list and search features to find essential information about your stock.
Expand Down
43 changes: 32 additions & 11 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,26 @@ Format: `bye`, `exit`, `quit`
---
<br>

### Getting Inspirational Quotes: `quote`

> This command fetches a random quote to uplift your spirits.
Need a little motivation? The quote command retrieves random inspirational messages to brighten your day. Whether you're feeling stuck or just need a boost, BinBash has got you covered!

Format: `quote`

The output will display a random quote in the format as seen below:
```text
-------------------------------------------------------------
Have a nice day!
-------------------------------------------------------------
```

> ℹ️ BinBash brings you a variety of inspiring messages to keep you motivated throughout your inventory management journey. So go ahead, type quote and let the positivity flow!
* [Back to table of contents](#table-of-contents)
---

### Saving and Loading data

Unsure as to how you can save your BinBash data? Don't worry! Your data is automatically saved to your local storage. No manual saving of data is required.
Expand All @@ -952,17 +972,18 @@ We highly recommended that you take a backup of your save file before editing it

## Command Summary

| **Command** | **Usage** | **Description** |
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| **add** | `add -re -n ITEM_NAME -d ITEM_DESCRIPTION -s SALE_PRICE -c COST_PRICE [-e EXPIRY_DATE] [-q ITEM_QUANTITY] [-t THRESHOLD]` <br> `add -op -n ITEM_NAME -d ITEM_DESCRIPTION -c COST_PRICE [-e EXPIRY_DATE] [-q ITEM_QUANTITY] [-t THRESHOLD]` | Adds a new item to the inventory. |
| **search** | `search -n NAME_QUERY -d DESCRIPTION_QUERY -q QUANTITY_RANGE -c COST_PRICE_RANGE -s SALE_PRICE_RANGE -e EXPIRY_DATE_RANGE -l NUMBER_OF_RESULTS` | Searches for items in the inventory based on various criteria. |
| **list** | `list` <br> `list -c` <br> `list -s` <br> `list -e` <br> `list -p` | Lists all items in the inventory, with optional sorting based on cost price, sale price, expiry date or profits. |
| **delete** | `delete -i ITEM_INDEX` <br> `delete -n ITEM_NAME` | Deletes an item from the inventory. |
| **sell** | `sell -n ITEM_NAME -q ITEM_QUANTITY` <br> `sell -i ITEM_INDEX -q ITEM_QUANTITY` | Decreases the quantity of an item after a sale. |
| **restock** | `restock -n ITEM_NAME -q ITEM_QUANTITY` <br> `restock -i ITEM_INDEX -q ITEM_QUANTITY` | Increases the quantity of an item after restocking. |
| **update** | `update -n ITEM_NAME [-d ITEM_DESCRIPTION] [-q ITEM_QUANTITY] [-e EXPIRY_DATE] [-s SALE_PRICE] [-c COST_PRICE] [-t THRESHOLD]` <br> `update -i ITEM_INDEX [-d ITEM_DESCRIPTION] [-q ITEM_QUANTITY] [-e EXPIRY_DATE] [-s SALE_PRICE] [-c COST_PRICE] [-t THRESHOLD]` | Updates the details of an existing item in the inventory. |
| **profit** | `profit` | Displays the total profit earned from the inventory. |
| **bye** | `bye` <br> `exit` <br> `quit` | Exits the application. |
| **Command** | **Usage** | **Description** |
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| **add** | `add -re -n ITEM_NAME -d ITEM_DESCRIPTION -q ITEM_QUANTITY -e EXPIRY_DATE -s SALE_PRICE -c COST_PRICE -t THRESHOLD` <br> `add -op -n ITEM_NAME -d ITEM_DESCRIPTION -q ITEM_QUANTITY -e EXPIRY_DATE -c COST_PRICE -t THRESHOLD` | Adds a new item to the inventory. |
| **search** | `search -n NAME_QUERY -d DESCRIPTION_QUERY -q QUANTITY_RANGE -c COST_PRICE_RANGE -s SALE_PRICE_RANGE -e EXPIRY_DATE_RANGE -l NUMBER_OF_RESULTS` | Searches for items in the inventory based on various criteria. |
| **list** | `list` <br> `list -c` <br> `list -s` <br> `list -e` <br> `list -p` | Lists all items in the inventory, with optional sorting based on cost price, sale price, expiry date or profits. |
| **delete** | `delete -i ITEM_INDEX` <br> `delete -n ITEM_NAME` | Deletes an item from the inventory. |
| **sell** | `sell -n ITEM_NAME -q ITEM_QUANTITY` <br> `sell -i ITEM_INDEX -q ITEM_QUANTITY` | Decreases the quantity of an item after a sale. |
| **restock** | `restock -n ITEM_NAME -q ITEM_QUANTITY` <br> `restock -i ITEM_INDEX -q ITEM_QUANTITY` | Increases the quantity of an item after restocking. |
| **update** | `update -n ITEM_NAME -d ITEM_DESCRIPTION -q ITEM_QUANTITY -e EXPIRY_DATE -s SALE_PRICE -c COST_PRICE -t THRESHOLD` <br> `update -i ITEM_INDEX -d ITEM_DESCRIPTION -q ITEM_QUANTITY -e EXPIRY_DATE -s SALE_PRICE -c COST_PRICE -t THRESHOLD` | Updates the details of an existing item in the inventory. |
| **profit** | `profit` | Displays the total profit earned from the inventory. |
| **quote** | `quote` | Displays a random quote on the screen. |
| **bye** | `bye` <br> `exit` <br> `quit` | Exits the application. |

<div id="infoCallout" style="padding: 1em; border: 0 solid #9ec1cf;border-left-width: 4px;border-radius: 6px; margin-top: 1rem; margin-bottom: 1rem; padding: 1em; border-radius: 4px; color: #293132; background-color: #eef9fc;">
ℹ️ <strong>Note:</strong>
Expand Down
47 changes: 47 additions & 0 deletions docs/team/XavierLiau34.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Xavier Liau - Project Portfolio Page

## Project: BinBash

BinBash is a CLI-based **Inventory Management System** that is targeted at small retail business owners.
BinBash aims to make the inventory management process streamlined, error-free and highly efficient, through its
extensive suite of inventory management features.
BinBash also enables users to gain valuable insights into their inventory, through comprehensive profit reporting
features which facilitate efficient sales and trends analysis.

Given below are my contributions to the project.

## Summary of Contributions

**New Feature:** Implemented `quote` command
- What it does: Provides a randomly generated quote upon input of the `quote` command.
- Justification: Enhances user experience by adding an entertaining and user-friendly feature.
- Highlights: The implementation generates quotes from a curated database and ensures random selection for variety.

**Implemented JUnit tests for several commands and parsers**

- What it does: Adds comprehensive test coverage, ensuring that the program behaves as expected under various scenarios and edge cases.
- Justification: Testing is a crucial aspect of software development, ensuring the reliability and correctness of the codebase.
By adding JUnit tests, we enhance the robustness of the application and reduce the likelihood of introducing regressions in future changes.
Increasing test coverage also helps identify and address potential bugs or issues, improving the overall quality of the application.
Comprehensive testing is the ultimate aim.
- Highlights: The JUnit tests cover different aspects, including testing for adding single items, multiple items,
item details correctness, handling duplicate item names, and handling zero quantity restocking, so on and so forth.

**Contributions to the User Guide**:
`quote` command section.

* **Contributions to the Developer Guide**:
* Logging section.
* BinBashLogger Class subsection.
* Usage subsection.
* Log Output subsection
* Product Scope section.
* Target User Profile subsection.
* Value Proposition subsection.
* Glossary Section
* Launch and Shutdown section.

* **Community Engagement**
* Conducted testing for other teams' applications and provided bug reports.

* **Code contributed**: [RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=XavierLiau34&breakdown=true)
2 changes: 1 addition & 1 deletion docs/team/pureusagi.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PureUsagi's Project Portfolio Page
# Ng Jun Han's Project Portfolio Page

## Project: BinBash

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/seedu/binbash/BinBash.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import seedu.binbash.inventory.ItemList;
import seedu.binbash.logger.BinBashLogger;
import seedu.binbash.parser.Parser;
import seedu.binbash.quotes.Quotes;
import seedu.binbash.storage.Storage;
import seedu.binbash.ui.Ui;

Expand All @@ -28,6 +29,7 @@ private void run() {

userInterface.greet();
userInterface.talk(itemList.getProfitMargin());
userInterface.talk(Quotes.getRandomQuote());

while (userInterface.isUserActive()) {
try {
Expand All @@ -46,7 +48,7 @@ private void run() {
}
logger.info("BinBash exiting...");
}

/**
* Main entry-point for the BinBash application.
*/
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/seedu/binbash/command/QuoteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package seedu.binbash.command;

import seedu.binbash.inventory.ItemList;
import seedu.binbash.quotes.Quotes;
import seedu.binbash.logger.BinBashLogger;

public class QuoteCommand extends Command {

public QuoteCommand() {
commandLogger = new BinBashLogger(QuoteCommand.class.getName());
commandLogger.info("Creating Quote Command...");
}

@Override
public boolean execute(ItemList itemList) {
executionUiOutput = Quotes.getRandomQuote();
return true;
}
}
4 changes: 4 additions & 0 deletions src/main/java/seedu/binbash/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import seedu.binbash.command.RestockCommand;
import seedu.binbash.command.ListCommand;
import seedu.binbash.command.ProfitCommand;
import seedu.binbash.command.QuoteCommand;

import seedu.binbash.exceptions.InvalidCommandException;

import org.apache.commons.cli.Option;
Expand Down Expand Up @@ -77,6 +79,8 @@ public Command parseCommand(String userInput) throws InvalidCommandException {
return parseUpdateCommand(commandArgs);
case "profit":
return new ProfitCommand();
case "quote":
return new QuoteCommand();
default:
throw new InvalidCommandException("Invalid command: " + commandString);
}
Expand Down
58 changes: 58 additions & 0 deletions src/main/java/seedu/binbash/quotes/Quotes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package seedu.binbash.quotes;

import java.util.Random;

public class Quotes {
public static final String[] CUSTOM_MESSAGES = {
"Hope you have a good day of inventory management.",
"Have a nice day!",
"Welcome back to BinBash!",
"Make today amazing!",
"Enjoy your time with BinBash!",
"Wishing you a productive day!",
"Get ready for some BinBash fun!",
"Let's make today great!",
"Time to conquer your inventory!",
"Sending positive vibes your way!",
"Welcome to another BinBash adventure!",
"Stay positive and keep BinBashing!",
"Today's a good day to organize!",
"You've got this!",
"Hope your day is BinBash-tastic!",
"Get ready to rock your inventory!",
"BinBash is here to help!",
"Hope you find everything you need!",
"Have a wonderful day ahead!",
"Start your day with a smile!",
"Sending you BinBash blessings!",
"Let's make magic happen!",
"Embrace the BinBash journey!",
"You're awesome, just like BinBash!",
"Seize the day with BinBash!",
"Welcome to BinBash excellence!",
"Time to unleash your inventory power!",
"Hope you have a blast with BinBash!",
"Today's a good day to BinBash!",
"Stay motivated and BinBash on!",
"Enjoy every moment with BinBash!",
"Make today memorable!",
"Let's create some BinBash miracles!",
"Believe in yourself and BinBash!",
"Welcome to the world of BinBash!",
"Today's forecast: BinBash brilliance!",
"BinBash wishes you a fantastic day!",
"May your day be filled with BinBash joy!",
"Let's make today legendary!",
"Stay positive and BinBash strong!"
};

private static final Random RANDOM = new Random();

// Private constructor to prevent instantiation
private Quotes() {}

public static String getRandomQuote() {
int randomIndex = RANDOM.nextInt(CUSTOM_MESSAGES.length);
return CUSTOM_MESSAGES[randomIndex];
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/binbash/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String readUserCommand() throws BinBashException {
* Prints a greeting message to standard output.
*/
public void greet() {
talk(LOGO + WELCOME_MESSAGE);
talk(NEWLINE + LOGO + WELCOME_MESSAGE);
}

/**
Expand Down
23 changes: 20 additions & 3 deletions src/test/java/seedu/binbash/command/ByeCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.jupiter.api.Test;
import seedu.binbash.inventory.ItemList;
import seedu.binbash.item.Item;

import java.util.ArrayList;

Expand All @@ -13,10 +12,28 @@ class ByeCommandTest {

@Test
void execute_exitBinBash_returnBye() {
command.execute(new ItemList(new ArrayList<Item>()));
String actualOutput = command.getExecutionUiOutput(); ;
command.execute(new ItemList(new ArrayList<>()));
String actualOutput = command.getExecutionUiOutput();
String expectedOutput = "Bye!";

assertEquals(expectedOutput, actualOutput);
}

@Test
void execute_multipleExecutions_returnByeConsistently() {
for (int i = 0; i < 5; i++) {
command.execute(new ItemList(new ArrayList<>()));
String actualOutput = command.getExecutionUiOutput();
String expectedOutput = "Bye!";
assertEquals(expectedOutput, actualOutput);
}
}

@Test
void execute_withNonNullItemList_returnBye() {
// Test behavior with a non-null ItemList
ItemList itemList = new ItemList(new ArrayList<>());
command.execute(itemList);
assertEquals("Bye!", command.getExecutionUiOutput());
}
}
17 changes: 15 additions & 2 deletions src/test/java/seedu/binbash/command/DeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.junit.jupiter.api.Test;

import seedu.binbash.inventory.ItemList;
import seedu.binbash.item.Item;

import java.time.LocalDate;
import java.util.ArrayList;
Expand All @@ -17,7 +16,7 @@ class DeleteCommandTest {

@BeforeEach
void setUp() {
itemList = new ItemList(new ArrayList<Item>());
itemList = new ItemList(new ArrayList<>());
itemList.addItem("retail", "test", "A test item", 2,
LocalDate.now(), 2.00, 1.00, 3);
}
Expand Down Expand Up @@ -56,4 +55,18 @@ void execute_invalidItemName_itemNotRemovedFromItemList() {

assertEquals(1, itemList.getItemCount());
}

@Test
void execute_removeDuplicateNamesOnlyOneRemoved() {
itemList.addItem("retail", "test", "Another test item", 1,
LocalDate.now(), 5.00, 2.00, 4); // Adding a duplicate item

assertEquals(1, itemList.getItemCount());

DeleteCommand deleteCommand = new DeleteCommand("test");
deleteCommand.execute(itemList);

assertEquals(0, itemList.getItemCount());
assertTrue(deleteCommand.hasToSave());
}
}
Loading

0 comments on commit 6b16d6b

Please sign in to comment.