Skip to content

Commit

Permalink
Merge pull request #160 from Cazh1/#158-Update-DG-with-Add-Order-feature
Browse files Browse the repository at this point in the history
#158 update dg with add order feature
  • Loading branch information
DextheChik3n authored Oct 30, 2023
2 parents 3059440 + 0ed5896 commit 6c0e557
Show file tree
Hide file tree
Showing 28 changed files with 232 additions and 84 deletions.
14 changes: 7 additions & 7 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

### Parser

![Parser Parsing User Input Sequence Diagram](umlimages/Parser.png)
![Parser Parsing User Input Sequence Diagram](images/sequence/Parser.png)

*Figure 1: Parser Parsing User Input Sequence Diagram*

Expand All @@ -22,7 +22,7 @@ When user input a string to `Main`, it passes the full user input to `Parser` v

### Add Dish

![Add Dish Execution](uml/AddDishCommand_execute.png)
![Add Dish Execution](images/sequence/AddDishCommand_execute.png)
*Figure X: Execution of add_dish command*

API: [AddDishCommand.java](https://github.com/AY2324S1-CS2113-T17-2/tp/blob/master/src/main/java/seedu/cafectrl/command/AddDishCommand.java)
Expand All @@ -39,9 +39,9 @@ Separation of Concerns was applied to ensure the `Ui` is only responsible with o
A list command can be used to display all the `Dish` objects stored in `Menu`.

The following class diagram illustrates the relationship between the respective classes involved in the creation and execution of a list command.
![List Menu Execution](umlimages/ListMenuCommandClass.png)
![List Menu Execution](images/class/ListMenuCommandClass.png)

![List Menu Execution](umlimages/ListMenuCommand_execute.png)
![List Menu Execution](images/sequence/ListMenuCommand_execute.png)

Figure 1: Execution of list_menu command

Expand All @@ -58,7 +58,7 @@ The data are then packaged nicely in a `leftAlignFormat`, with (indexNum + ". "
e.g. (1. Chicken Rice $2.50) is shown.

### List Ingredients
![List Ingredient Execution](umlimages/ListIngredientCommand_execute.png)
![List Ingredient Execution](images/sequence/ListIngredientCommand_execute.png)

*Figure 2: Execution of list_ingredient command*

Expand All @@ -77,7 +77,7 @@ API: [ListIngredientCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/

### Delete Dish

![Delete Dish Execution](uml/DeleteDishCommand_execute.png)
![Delete Dish Execution](images/sequence/DeleteDishCommand_execute.png)
<br>*Figure X: Execution of delete dish command

API: [DeleteDishCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/DeleteDishCommand.java)
Expand All @@ -95,7 +95,7 @@ This sequence of actions orchestrates the flow of information and operations bet

### Edit Price

![Edit Price Execution](umlimages/EditPriceCommand_execute.png)
![Edit Price Execution](images/sequence/EditPriceCommand_execute.png)

*Figure 3: Execution of edit_price command*

Expand Down
89 changes: 89 additions & 0 deletions docs/diagrams/class/AddOrderCommandClass.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@startuml
'https://plantuml.com/class-diagram

CafeCtrl "1" --> "1" UI
CafeCtrl "1" --> "1" Parser
CafeCtrl "1" --> "1" Sales
CafeCtrl "1" --> "1" Pantry
CafeCtrl "1" o-- "*" Command

Command <|- AddOrderCommand
Parser "1" --> "*" AddOrderCommand
AddOrderCommand --> OrderList
AddOrderCommand "1" --> "1" Chef
AddOrderCommand --> Pantry
OrderList "1" --> "*" Order
Sales --> "1...*" OrderList

class CafeCtrl {
- setup()
- run()
+ main(args : String[])
}

class Command {

}

class UI {
{static} - scanner : Scanner
+ receiveUserInput() : String
+ showMenuTop() : void
+ showChefMessage() : void
+ showTotalCost(dollarCost : String) : void
}

class AddOrderCommand {
# orderList : OrderList
# ui : Ui
# pantry : Pantry
+ execute() : void
}

class Parser {
{static} + parseCommand(menu : Menu, userInput : String, ui : Ui, pantry : Pantry, sales : Sales, currentDate : CurrentDate) : Command
{static} - prepareOrder(menu : Menu, arguments : String, ui : Ui, pantry : Pantry, sales : Sales, currentDate : CurrentDate) : Command
}

class OrderList {
- orderList : ArrayList<Order>
- totalOrderListCost : float
+ addOrder() : void
+ addCost() : void
+ getTotalCost() : float
}

class Order {
- orderedDish : Dish
- dishQty : int
- ingredientList : ArrayList<Ingredient>
- isComplete : boolean
- totalOrderCost : float
- getDishPrice() : float
- setIngredientList() : ArrayList<Ingredient>
+ getIngredientList() : ArrayList<Ingredient>
+ getTotalOrderCost() : float
+ setComplete() : void
+ getIsComplete() : boolean
}

class Chef {
- order : Order
- pantry : Pantry
- ui : Ui
+ cookDish() : void
}

class Pantry {
- pantryStock : ArrayList<Ingredient>
- menuItems : ArrayList<Dish>
- ui : Ui
+ decreaseIngredientsStock(dishIngredient : ArrayList<Ingredient>) : void
}

class Sales {
- orderLists : ArrayList<OrderList>
- daysAccounted : int
}

@enduml
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions docs/diagrams/sequence/AddOrderCommand_execute.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@startuml
'https://plantuml.com/sequence-diagram

autonumber

-> ":AddOrderCommand" : execute()
activate ":AddOrderCommand"
":AddOrderCommand" -> ":OrderList" : addOrder(order : Order)
activate ":OrderList"
return
":AddOrderCommand" -> ":Chef" : new Chef(order : Order, pantry : Pantry, ui : Ui)
activate ":Chef"
return chef : Chef
":AddOrderCommand" -> ":Chef" : cookDish()
activate ":Chef"
opt !order.isComplete()
":Chef" -> ":Ui" : showChefMessage()
activate ":Ui"
":Ui" -> ":Ui" : showToUser(args : String)
activate ":Ui"
return
return
":Chef" -> ":Order" : getIngredientList()
activate ":Order"
return ingredientList : ArrayList<Ingredient>
":Chef" -> ":Pantry" : decreaseIngredientsStock(ingredientList : ArrayList<Ingredient>)
activate ":Pantry"
return
":Chef" -> ":Order" : setComplete()
activate ":Order"
return
end
":Chef" -> ":Ui" : showToUser(args : String)
activate ":Ui"
return
return
opt order.isComplete()
":AddOrderCommand" -> ":OrderList" : addCost(order : Order)
activate ":OrderList"
return
end
":AddOrderCommand" -> ":OrderList" : getTotalCost()
activate ":OrderList"
return totalOrderListCost : float
":AddOrderCommand" -> ":Ui" : showTotalCost(totalOrderListCost)
activate ":Ui"
":Ui" -> ":Ui" : showToUser(args : String)
activate ":Ui"
return
return
return
@enduml
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@startuml
'https://plantuml.com/sequence-diagram

autonumber

Main -> EditPriceCommand: execute()
activate EditPriceCommand
EditPriceCommand -> Dish: setPrice(price: float)
activate Dish
EditPriceCommand -> Ui: showEditPriceMessages()
deactivate EditPriceCommand
deactivate Dish
@enduml
@startuml
'https://plantuml.com/sequence-diagram

autonumber

Main -> EditPriceCommand: execute()
activate EditPriceCommand
EditPriceCommand -> Dish: setPrice(price: float)
activate Dish
EditPriceCommand -> Ui: showEditPriceMessages()
deactivate EditPriceCommand
deactivate Dish
@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,45 @@ autonumber



--> ":ListMenuCommand" : execute()
-> ":ListMenuCommand" : execute()
activate ":ListMenuCommand"
alt menu.getSize() == 0
":ListMenuCommand" --> ":ListMenuCommand" : printEmptyMenu(ui)
":ListMenuCommand" --> ":Ui" : showEmptyMenu()
":ListMenuCommand" -> ":ListMenuCommand" : printEmptyMenu(ui)
":ListMenuCommand" -> ":Ui" : showEmptyMenu()
activate ":Ui"
":Ui" -> ":Ui" : showToUser(message: String)
activate ":Ui"
return
return
else
":ListMenuCommand" --> ":ListMenuCommand" : printFullMenu(menu, ui)
":ListMenuCommand" --> ":Ui" : showMenuTop()
":ListMenuCommand" -> ":ListMenuCommand" : printFullMenu(menu, ui)
":ListMenuCommand" -> ":Ui" : showMenuTop()
activate ":Ui"
":Ui" -> ":Ui" : showToUser(message: String)
activate ":Ui"
return
return
loop Dish : Menu
":ListMenuCommand" --> ":Menu" : getDishFromId(id)
":ListMenuCommand" -> ":Menu" : getDishFromId(id)
activate ":Menu"
":Menu" --> ":ListMenuCommand" : (selectedDish : Dish)
deactivate ":Menu"
":ListMenuCommand" --> ":Dish" : selectedDish.getName()
":ListMenuCommand" -> ":Dish" : selectedDish.getName()
activate ":Dish"
":Dish" --> ":ListMenuCommand" : (dishName : String)
deactivate ":Dish"
":ListMenuCommand" --> ":Dish" : selectedDish.getPrice()
":ListMenuCommand" -> ":Dish" : selectedDish.getPrice()
activate ":Dish"
":Dish" --> ":ListMenuCommand" : (dishPrice : String)
deactivate ":Dish"
":ListMenuCommand" --> ":Ui" : showMenuDish()
":ListMenuCommand" -> ":Ui" : showMenuDish()
activate ":Ui"
":Ui" -> ":Ui" : showToUser(message: String)
activate ":Ui"
return
return
end
":ListMenuCommand" --> ":Ui" : showMenuBottom() : String)
":ListMenuCommand" -> ":Ui" : showMenuBottom() : String)
activate ":Ui"
":Ui" -> ":Ui" : showToUser(message: String)
activate ":Ui"
Expand Down
52 changes: 26 additions & 26 deletions docs/umldiagrams/Parser.puml → docs/diagrams/sequence/Parser.puml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
@startuml
'https://plantuml.com/sequence-diagram

actor User

User -> Main: fullUserInput
activate Main
Main -> Parser: parseCommand(fullUserInput: String)
activate Parser

alt COMMAND_WORD
Parser -> Parser: prepareCommand(requiredArguments)
activate Parser
Parser -> Command: Command()
activate Command
Command --> Parser: command
deactivate Command
deactivate Parser
end alt

deactivate Parser

Parser --> Main: command
Main -> Command: execute()
activate Command
@enduml
@startuml
'https://plantuml.com/sequence-diagram

actor User

User -> Main: fullUserInput
activate Main
Main -> Parser: parseCommand(fullUserInput: String)
activate Parser

alt COMMAND_WORD
Parser -> Parser: prepareCommand(requiredArguments)
activate Parser
Parser -> Command: Command()
activate Command
Command --> Parser: command
deactivate Command
deactivate Parser
end alt

deactivate Parser

Parser --> Main: command
Main -> Command: execute()
activate Command
@enduml
Binary file added docs/images/class/AddOrderCommandClass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added docs/images/sequence/AddOrderCommand_execute.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/command/AddOrderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void execute() {
Chef chef = new Chef(order, pantry, ui);
chef.cookDish();
//pantry.printPantryStock();
if (order.isComplete()) {
if (order.getIsComplete()) {
orderList.addCost(order);
}
ui.showTotalCost(dollarValue.format(orderList.getTotalOrderListCost()));
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/seedu/cafectrl/data/Chef.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package seedu.cafectrl.data;

import seedu.cafectrl.ui.Messages;
import seedu.cafectrl.ui.Ui;

public class Chef {
protected Order order;
protected Pantry pantry;
protected Ui ui;
private final Order order;
private final Pantry pantry;
private final Ui ui;

public Chef(Order order, Pantry pantry, Ui ui) {
this.order = order;
Expand All @@ -16,12 +15,12 @@ public Chef(Order order, Pantry pantry, Ui ui) {

public void cookDish() {
try {
if (!order.isComplete) {
ui.showToUser(Messages.CHEF_MESSAGE);
pantry.decreaseIngredientsStock(order.usedIngredientList);
if (!order.getIsComplete()) {
ui.showChefMessage();
pantry.decreaseIngredientsStock(order.getIngredientList());
order.setComplete();
}
ui.showToUser("Is order completed?: " + order.isComplete);
ui.showToUser("Is order completed?: " + order.getIsComplete());
} catch (Exception e) {
ui.showToUser("Unable to cook: " + e.getMessage());
}
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/seedu/cafectrl/data/CurrentDate.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.cafectrl.data;

public class CurrentDate {
protected int currentDay;
private int currentDay;

public CurrentDate() {
currentDay = 0;
Expand All @@ -18,8 +18,4 @@ public void previousDay() {
public int getCurrentDay() {
return currentDay;
}

public void setCurrentDay(int currentDay) {
this.currentDay = currentDay;
}
}
Loading

0 comments on commit 6c0e557

Please sign in to comment.