Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T17-2/tp
Browse files Browse the repository at this point in the history
…into 326-junit-dg-javadoc
  • Loading branch information
ShaniceTang committed Nov 13, 2023
2 parents 7d79f50 + 0962c62 commit 3876bb9
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 107 deletions.
3 changes: 2 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
* [Target user profile](#target-user-profile)
* [Value proposition](#value-proposition)
* [User stories](#user-stories)
<!-- TOC -->--------------------------------------------------------------------------------------------------------------
<!-- TOC -->
--------------------------------------------------------------------------------------------------------------
## **Acknowledgements**

[addressbook-level2](https://github.com/se-edu/addressbook-level2) <br>
Expand Down
20 changes: 10 additions & 10 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
* [Features](#features)
* [Viewing help : `help`](#viewing-help--help)
* [Adding a dish : `add`](#adding-a-dish--add)
* [Listing all menu items : `list_menu`](#listing-all-menu-items--listmenu)
* [Listing ingredients needed for the selected dish : `list_ingredients`](#listing-ingredients-needed-for-the-selected-dish--listingredients)
* [Listing all menu items : `list_menu`](#listing-all-menu-items--list_menu)
* [Listing ingredients needed for the selected dish : `list_ingredients`](#listing-ingredients-needed-for-the-selected-dish--list_ingredients)
* [Deleting a menu item : `delete`](#deleting-a-menu-item--delete)
* [Editing price of menu item : `edit_price`](#editing-price-of-menu-item--editprice)
* [Viewing the total stock of ingredients : `view_stock`](#viewing-the-total-stock-of-ingredients--viewstock)
* [Buying an ingredient : `buy_ingredient`](#buying-an-ingredient--buyingredient)
* [Showing all sales : `show_sales`](#showing-all-sales--showsales)
* [Showing sales for a chosen day : `show_sale`](#showing-sales-for-a-chosen-day--showsale)
* [Adding an order : `add_order`](#adding-an-order--addorder)
* [Returning to the previous day: `previous_day`](#returning-to-the-previous-day-previousday)
* [Advancing to the next day: `next_day`](#advancing-to-the-next-day-nextday)
* [Editing price of menu item : `edit_price`](#editing-price-of-menu-item--edit_price)
* [Viewing the total stock of ingredients : `view_stock`](#viewing-the-total-stock-of-ingredients--view_stock)
* [Buying an ingredient : `buy_ingredient`](#buying-an-ingredient--buy_ingredient)
* [Showing all sales : `list_total_sales`](#showing-all-sales--list_total_sales)
* [Showing sales for a chosen day : `list_sale`](#showing-sales-for-a-chosen-day--list_sale)
* [Adding an order : `add_order`](#adding-an-order--add_order)
* [Returning to the previous day: `previous_day`](#returning-to-the-previous-day-previous_day)
* [Advancing to the next day: `next_day`](#advancing-to-the-next-day-next_day)
* [Exiting the program : `bye`](#exiting-the-program--bye)
* [Known Issues](#known-issues)
* [Command Summary](#command-summary)
Expand Down
Binary file modified docs/images_PPP/zhongheng/Assist_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images_PPP/zhongheng/Bug_reporting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images_PPP/zhongheng/Pantry_load_from_file_bug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images_PPP/zhongheng/Pantry_restock_bug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 30 additions & 43 deletions docs/team/cazh1.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,92 @@
# Zhong Heng - Project Portfolio Page
### Zhong Heng - Project Portfolio Page
**Project: CafeCRTL**

-----------------------------------------------------------------------------------------------
## **Overview**
CaféCTRL is a software engineering project for CS2113. The user interacts with the application through CLI. It has around 6 kLoC, and it is done in a team of 5.
**Overview** - CaféCTRL is a software engineering project for CS2113. The user interacts with the application through CLI. It has around 6 kLoC, and it is done in a team of 5.

## **Value Proposition**
CaféCRTL aims to optimize managing of inventory and cash flow in a restaurant. Our CLI platform empowers Café proprietors to streamline inventory and menu management.

## **Target User**
Café proprietors who prefer typing on CLI than any other interaction method and are seeking for a software solution to optimize the management of their café's operations.

-----------------------------------------------------------------------------------------------
**Value Proposition** - CaféCRTL aims to optimize managing of inventory and cash flow in a restaurant. Our CLI platform empowers Café proprietors to streamline inventory and menu management.

**Target User** - Café proprietors who prefer typing on CLI than any other interaction method and are seeking for a software solution to optimize the management of their café's operations.

### Summary of Contributions

### Code Contribution
[Follow here to see code written by me](https://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=cazh1&breakdown=true)

### Enhancements implemented
**Code Contribution** - [Follow here to see code written by me](https://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=cazh1&breakdown=true)

#### Feature
#### Feature implemented

1. **List Menu** <br>
Function: Allow user to view all dishes added to menu <br>
Command Format: `list_menu`
<br/><br/>
<br/>
2. **Add Order** <br>
Function: Adds an order consisting of dishes off the menu to an order list <br>
Command Format: `add_order name/DISH_NAME qty/DISH_QTY`<br>
Error Handling: This command is able to detect missing argument tag, missing argument, wrong argument type, empty argument type. It will then output specific error message to prompt the user to enter the correct Command format. <br>
Highlights: This feature required the creation of 5 classes to work together to perform the intended task. This really tested my understanding of OOP and planning to minimise overlap and manage the interactions between these classes.
<br/><br/>
3. **Day Change Commands** <br>
Added the ability to traverse through different days. <br>
<br/>
3. **Day Change Commands** - Added the ability to traverse through different days. <br>
Function: Next Day and Previous Day commands allow the user to traverse through different days to capture sales, simulating a sales system used in a restaurant. <br>
Command Format: `next_day` and `previous_day`<br>
Error Handling: Next Day command ensures that the intended traversed day has a proper orderList, preventing a NullPointerException. Previous Day command will prevent the user from traversing to days before Day 1. <br>
Highlights: This feature required strong understanding of ArrayLists as it worked with multiple layers of ArrayLists as well as different copies of the same ArrayList that needed to be synchronised.
<br/><br/>
4. **Hashing text save files** <br>
Implemented Hashing for text files used to save app user input data. <br>
What it does: Hashes the text files generated from user actions (such as Menu, Sales and PantryStock), that will be accessed to load relevant data back into the application. When tampering has been detected, the syntax is shown to the user to ensure that the user is able to adjust the data saved while maintaining the format that the application is able to process.<br>
Justification: This was done to detect tampering of these save files which may potentially crash or induce unexpected behaviour from the application when the data is read and loaded into the application. <br>
Highlights: This feature relied on knowledge learnt in CS2040C, Data Structures and Algorithms, to come up with the idea, understand how hashing works and how to implement this feature.<br>
Credits: https://www.geeksforgeeks.org/java-string-hashcode-method-with-examples/ <br>
Implemented in PRs: [#283](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/283), [#324](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/324)
<br/><br/>
<br/>
4. **Hashing text save files** - Implemented Hashing for text files used to save app user input data. <br>
What it does: Hashes the text files generated from user actions (such as Menu, Sales and PantryStock), that will be accessed to load relevant data back into the application. When tampering has been detected, the syntax is shown to the user to ensure that the user is able to adjust the data saved while maintaining the format that the application is able to process.<br>
Justification: This was done to detect tampering of these save files which may potentially crash or induce unexpected behaviour from the application when the data is read and loaded into the application. <br>
Highlights: This feature relied on knowledge learnt in CS2040C, Data Structures and Algorithms, to come up with the idea, understand how hashing works and how to implement this feature.<br>
Credits: https://www.geeksforgeeks.org/java-string-hashcode-method-with-examples/ <br>
Implemented in PRs: [#283](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/283), [#324](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/324)

### Enhancement
#### Enhancements Implemented
1. **Main**<br>
Implemented skeleton code for Main for other teammates to use.
<br><br>
<br>
2. **Parser**<br>
Implemented skeleton class for Parser for other teammates to use. I refactored Parser such that only relevant parameters are passed into commands when executing. This removes bloat from the Command class and leaves the work to the Parser class.
<br><br>
<br>
3. **Command**<br>
Implemented skeleton class for Command for other teammates to use. I refactored existing Command classes such that only relevant parameters are passed into commands when executing.
<br><br>
<br>
4. **Order**<br>
Implemented class for Order, OrderList, Sales and Chef. These classes are accessed by Pantry and Menu for features relating to Orders and Sales, accounting for 1/3 of the application features.
<br><br>
<br>
5. **Printing**<br>
Implemented the printing style of auto formatting box used by `list_menu`, `view_stock` and `show_sales`.
<br><br>
<br>
6. **Order**<br>
Implemented class for CurrentDate. This class is used to facilitate the day changes and sales.
<br><br>
<br>

### Contributions to UG
#### Contributions to UG
[UserGuide](https://ay2324s1-cs2113-t17-2.github.io/tp/UserGuide.html)

1. List Menu
2. Add Order
3. Next Day
4. Previous Day

### Contributions to DG
#### Contributions to DG
1. List Menu
2. Add Order
3. Next Day
4. Previous Day

### Other Contributions to Team-based Task
#### Other Contributions to Team-based Task
1. Maintain issue tracker
2. Bug testing for the application and providing detailed steps to recreate found bugs. <br>
![Bugs Found](../images_PPP/zhongheng/Bug_reporting.png)
![Bugs Found](../images_PPP/zhongheng/Pantry_load_from_file_bug.png)
![Bugs Found](../images_PPP/zhongheng/Bug_reporting.png)
![Bugs Found](../images_PPP/zhongheng/Pantry_restock_bug.png)
3. Implemented bug fixes for PED bugs
[#212](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/212),
[#278](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/278),
[#297](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/297)
### Review/Mentoring Contributions
#### Review/Mentoring Contributions
1. Reviewed and approved PRs.
Some examples of PR reviewed: [#321](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/321),
[#296](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/296),
[#57](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/57),
[#96](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/96)
2. Assist teammates with their acclimation to the project's workflow, particularly using GitHub's branching workflow.
2. Assist teammates with their acclimation to the project's workflow, particularly using GitHub's branching workflow. <br>
![Assist_workflow](../images_PPP/zhongheng/Assist_workflow.png)
### Contributions beyond the Project Team
#### Contributions beyond the Project Team
1. Reported a total of [16 program bugs](https://github.com/Cazh1/ped/issues) for another team during the module's PED.
11 changes: 6 additions & 5 deletions docs/team/dexthechik3n.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ e.g checking for repeated dish/ingredient name, invalid price type, missing argu
### Review/mentoring contributions
* Examples of PRs reviewed:
[#98](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/98), [#119](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/119), [#190](https://github.com/AY2324S1-CS2113-T17-2/tp/pull/190)
* Managed the project team discussions by providing a meeting outline
![Screenshot of Project Outline 1](../images_PPP/dexter/project_discussion1.png)<br>
* Managed the project team discussions by providing a meeting outline <br>
<img alt="Screenshot of Project Outline 1" src="../images_PPP/dexter/project_discussion1.png" height="200" width="250"/>
![Screenshot of Project Outline 2](../images_PPP/dexter/project_discussion2.png)<br>
* Provided a summary of the division of labour after meetings
![Notion Screenshot](../images_PPP/dexter/division_of_labour1.png)<br>
![Telegram Screenshot](../images_PPP/dexter/division_of_labour.png)<br>
* Provided a summary of the division of labour after meetings <br>
* <img alt="Telegram Screenshot" height="325" src="../images_PPP/dexter/division_of_labour.png" width="200"/>
<img alt="Notion Screenshot" height="100" src="../images_PPP/dexter/division_of_labour1.png" width="300"/>
<br>

### Contributions beyond the project team
Reported bugs and suggestions for other teams in the class <br>
Expand Down
59 changes: 19 additions & 40 deletions src/main/java/seedu/cafectrl/storage/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.logging.Logger;

//@@author DextheChik3n
/**
* Manage everything related to file such as writing, reading, opening and creating file
Expand Down Expand Up @@ -55,8 +55,13 @@ public ArrayList<String> readTextFile(String filePath) throws FileNotFoundExcept
* Checks if the text file and folder exists in the user's system and creates them (if needed)
* @param filePath the specified path location of the file
*/
public void checkFileExists(String filePath) throws IOException {
public void checkFileExists(String filePath) throws Exception {
logger.info("Checking if " + filePath + " exists...");

if (filePath.isEmpty()) {
throw new Exception(ErrorMessages.MISSING_FILEPATH);
}

String userWorkingDirectory = System.getProperty("user.dir");
Path dataFilePath = Paths.get(userWorkingDirectory, filePath);
Path dataFolderPath = dataFilePath.getParent();
Expand All @@ -83,45 +88,19 @@ public void checkFileExists(String filePath) throws IOException {
*
* @param filePath file path of the text file.
* @param listOfTextToAdd text to be written to the text file.
* @throws IOException If I/O operations are interrupted.
*/
public void overwriteFile(String filePath, ArrayList<String> listOfTextToAdd) throws IOException {
checkFileExists(filePath);
FileWriter fw = new FileWriter(filePath);
for (String line : listOfTextToAdd) {
logger.info("Overwriting " + filePath + " with " + line + "...");
fw.write(line);
}
fw.close();
}

/**
* Writes text to the text file at the specified file path.
* Will overwrite all text in text file.
*
* @param filePath file path of the text file.
* @param textToAdd text to be written to the text file.
* @throws IOException If I/O operations are interrupted.
*/
public void overwriteFile(String filePath, String textToAdd) throws IOException {
checkFileExists(filePath);
FileWriter fw = new FileWriter(filePath);
fw.write(textToAdd);
fw.close();
}
public void overwriteFile(String filePath, ArrayList<String> listOfTextToAdd) {
try {
checkFileExists(filePath);
FileWriter fw = new FileWriter(filePath);
for (String line : listOfTextToAdd) {
logger.info("Overwriting " + filePath + " with " + line + "...");
fw.write(line);
}

/**
* Appends text to the text file at the specified file path.
* Will add text to text file.
*
* @param filePath file path of the text file.
* @param textToAdd text to be added to the text file.
* @throws IOException If I/O operations are interrupted.
*/
public void appendToFile(String filePath, String textToAdd) throws IOException {
checkFileExists(filePath);
FileWriter fw = new FileWriter(filePath, true);
fw.write(textToAdd);
fw.close();
fw.close();
} catch (Exception e) {
ui.showToUser(e.getMessage());
}
}
}
1 change: 1 addition & 0 deletions src/main/java/seedu/cafectrl/ui/ErrorMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ public class ErrorMessages {
+ "is inaccurate and will hence be updated from %.2f to %.2f instead.";
public static final String WRONG_HELP_FORMAT = "Invalid help command format!\n"
+ HelpCommand.MESSAGE_USAGE;
public static final String MISSING_FILEPATH = "Error in FileManager: No File Path entered";
}
8 changes: 0 additions & 8 deletions src/test/java/seedu/cafectrl/UiTest.java

This file was deleted.

64 changes: 64 additions & 0 deletions src/test/java/seedu/cafectrl/storage/FileManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package seedu.cafectrl.storage;

import org.junit.jupiter.api.Test;
import seedu.cafectrl.ui.ErrorMessages;
import seedu.cafectrl.ui.Ui;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;

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

/**
* Junit test for FileManager.java
*/
public class FileManagerTest {
@Test
public void readTextFile_emptyFilePath_fileNotFoundExceptionThrown() {
String inputFilePath = "";

FileManager fileManager = new FileManager(new Ui());
assertThrows(FileNotFoundException.class, () -> fileManager.readTextFile(inputFilePath));
}

@Test
public void readTextFile_nullFilePath_nullPointerExceptionThrown() {

FileManager fileManager = new FileManager(new Ui());
assertThrows(NullPointerException.class, () -> fileManager.readTextFile(null));
}

@Test
public void checkFileExists_emptyFilePath_fileNotFoundExceptionThrown() {
String inputFilePath = "";

FileManager fileManager = new FileManager(new Ui());
assertThrows(Exception.class, () -> fileManager.checkFileExists(inputFilePath));
}

@Test
public void checkFileExists_nullFilePath_nullPointerExceptionThrown() {
FileManager fileManager = new FileManager(new Ui());
assertThrows(NullPointerException.class, () -> fileManager.checkFileExists(null));
}

@Test
public void overwriteFile_emptyFilePath_emptyFileInputMessage() {
ArrayList<String> actualOutput = new ArrayList<>();
Ui ui = new Ui() {
@Override
public void showToUser(String... message) {
actualOutput.addAll(Arrays.asList(message));
}
};
FileManager fileManager = new FileManager(ui);

String inputFilePath = "";
ArrayList<String> inputTextList = new ArrayList<>();

fileManager.overwriteFile(inputFilePath, inputTextList);
assertEquals(ErrorMessages.MISSING_FILEPATH, actualOutput.get(0));
}
}

0 comments on commit 3876bb9

Please sign in to comment.