Skip to content

Commit

Permalink
Merge pull request #186 from Cazh1/#159-Update-DG-with-Multi-day-Orde…
Browse files Browse the repository at this point in the history
…r-feature

#159 Update DG with Multi-day Order feature
  • Loading branch information
DextheChik3n authored Nov 1, 2023
2 parents 770508a + 0c3c380 commit ff6892e
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 35 deletions.
43 changes: 42 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The following class diagram illustrates the relationship between the respective

![Add_order Execution](images/sequence/AddOrderCommand_execute.png)

Figure 1: Execution of add_order command
Figure 2: Execution of add_order command

API: [AddOrderCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/ListMenuCommand.java)

Expand All @@ -100,6 +100,47 @@ After verifying that the order has been completed, the cost of the order is adde
The total sum of orders in the `orderList` object is retrieved using `orderList.getTotalCost()`.
This is then passed into Ui using `ui.showTotalCost()` to display a message to the user with the total order cost.

### Next Day
A `next_day` command can be used advance the current day.

The following class diagram illustrates the relationship between the respective classes involved in the creation and execution of a next_day command.
![Next_Day Execution](images/class/NextDayCommandClass.png)

![Next_Day Execution](images/sequence/NextDayCommand_execute.png)

Figure 3: Execution of next_day command

API: [NextDayCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/ListMenuCommand.java)

When the `execute()` method of NextDayCommand is invoked in Main, the day in the program is advanced by 1 day, by running `currentDate.nextDay()`.

The next day data is retrieved from the `CurrentDate` object using `currentDate.getCurrentDay()`.
This next day data is compared with the days accounted for in the `Sales` object, retrieved using `sales.getDaysAccounted()`.

If the next day is more than the number of days accounted in sales, this means that there is no `orderList` prepared for the coming day.
A new `OrderList` object is created using `new OrderList()`, and added into the `Sales` object by running `sales.addOrderList()`.
Following this, the day has been accounted and this is updated through `sales.nextDay()`.

To end off the command, `ui.showNextDay()` is run to display a message to the user a prepared message for advancing the day.
The user is also shown the advanced day number.

### Previous Day
A `previous_day` command can be used to recede the current day.

The following class diagram illustrates the relationship between the respective classes involved in the creation and execution of a next_day command.
![Previous_Day Execution](images/class/PreviousDayCommandClass.png)

![Previous_Day Execution](images/sequence/PreviousDayCommand_execute.png)

Figure 4: Execution of previous_day command

API: [PreviousDayCommand.java]({repoURL}src/main/java/seedu/cafectrl/command/ListMenuCommand.java)

When the `execute()` method of PreviousDayCommand is invoked in Main, the day in the program is receded by 1 day, by running `currentDate.previousDay()`.

To end off the command, `ui.showPreviousDay()` is run to display a message to the user a prepared message for receding the day.
The user is also shown the receded day number.

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

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

title Class Diagram of CafeCtrl `add_order` Command

CafeCtrl "1" --> "1" UI
CafeCtrl "1" --> "1" Parser
CafeCtrl "1" --> "1" Sales
Expand All @@ -10,12 +12,15 @@ CafeCtrl "1" o-- "*" Command

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

class CafeCtrl {
- setup()
Expand All @@ -28,23 +33,26 @@ class Command {
}

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

class AddOrderCommand {
# orderList : OrderList
# ui : Ui
# pantry : Pantry
# orderList : OrderList
# menu : Menu
- ui : Ui
- order : Order
+ 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
{static} - setOrderList(currentDate : CurrentDate, sales : Sales)
}

class OrderList {
Expand Down Expand Up @@ -80,12 +88,13 @@ class Pantry {
- pantryStock : ArrayList<Ingredient>
- menuItems : ArrayList<Dish>
- ui : Ui
+ decreaseIngredientsStock(dishIngredient : ArrayList<Ingredient>) : void
+ isDishCooked( :ArrayList<Ingredient>) : boolean
+ calculateDishAvailability(menu : Menu) : void
}

class Sales {
- orderLists : ArrayList<OrderList>
- daysAccounted : int
+ getOrderList(index : int) : OrderList
}

class CurrentDate {
Expand Down
8 changes: 4 additions & 4 deletions docs/diagrams/class/ListMenuCommandClass.puml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CafeCtrl "1" o-- "*" Command
Command <|- ListMenuCommand
Parser "1" --> "*" ListMenuCommand
ListMenuCommand --> Menu
Menu --> "*" Dish
Menu -- "*" Dish

class CafeCtrl {
- setup()
Expand All @@ -25,7 +25,7 @@ class Command {
}

class UI {
{static} - scanner : Scanner
- scanner : Scanner
+ receiveUserInput() : String
+ showMenuTop() : void
+ showMenuBottom() : void
Expand All @@ -34,8 +34,8 @@ class UI {
}

class ListMenuCommand {
# menu : Menu
# ui : Ui
- menu : Menu
- ui : Ui
+ execute() : void
+ printEmptyMenu(ui : Ui) : void
+ printFullMenu(menu : Menu, ui : Ui)
Expand Down
6 changes: 4 additions & 2 deletions docs/diagrams/class/NextDayCommandClass.puml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@startuml
'https://plantuml.com/class-diagram

title Class Diagram of CafeCtrl `next_day` Command

CafeCtrl "1" --> "1" UI
CafeCtrl "1" --> "1" Parser
CafeCtrl "1" --> "1" Sales
Expand All @@ -9,7 +11,7 @@ CafeCtrl "1" o-- "*" Command

Command <|- NextDayCommand
Parser "1" --> "*" NextDayCommand
NextDayCommand --> OrderList
NextDayCommand ..> OrderList : Creates >
NextDayCommand --> CurrentDate
NextDayCommand --> Sales
Sales --> "1...*" OrderList
Expand All @@ -25,7 +27,7 @@ class Command {
}

class UI {
{static} - scanner : Scanner
- scanner : Scanner
+ receiveUserInput() : String
+ showToUser() : void
+ printLine() : void
Expand Down
8 changes: 5 additions & 3 deletions docs/diagrams/class/PreviousDayCommandClass.puml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@startuml
'https://plantuml.com/class-diagram

CafeCtrl "1" --> "1" UI
title Class Diagram of CafeCtrl `previous_day` Command

CafeCtrl "1" --> "1" Ui
CafeCtrl "1" --> "1" Parser
CafeCtrl "1" --> "1" CurrentDate
CafeCtrl "1" o-- "*" Command
Expand All @@ -21,8 +23,8 @@ class Command {

}

class UI {
{static} - scanner : Scanner
class Ui {
- scanner : Scanner
+ receiveUserInput() : String
+ showToUser() : void
+ printLine() : void
Expand Down
25 changes: 11 additions & 14 deletions docs/diagrams/sequence/AddOrderCommand_execute.puml
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,28 @@ autonumber
return
":Chef" -> ":Order" : getIngredientList()
activate ":Order"
return ingredientList : ArrayList<Ingredient>
":Chef" -> ":Pantry" : decreaseIngredientsStock(ingredientList : ArrayList<Ingredient>)
return :ArrayList<Ingredient>
":Chef" -> ":Pantry" : isDishCooked(:ArrayList<Ingredient>)
activate ":Pantry"
return
":Chef" -> ":Order" : setComplete()
return isComplete : boolean
":Chef" -> ":Order" : setComplete(isComplete : boolean)
activate ":Order"
return
end
":Chef" -> ":Ui" : showToUser(args : String)
":Chef" -> ":Ui" : showOrderStatus(args : String)
activate ":Ui"
":Ui" -> ":Ui" : showToUser(args : String)
activate ":Ui"
return
return
":Chef" -> ":Pantry" : calculateDishAvailability(menu : Menu)
activate ":Pantry"
return
return
opt order.getIsComplete()
":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
Binary file modified 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.
Binary file modified docs/images/class/ListMenuCommandClass.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/class/NextDayCommandClass.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 removed docs/images/class/PreviousDayCommand.png
Binary file not shown.
Binary file added docs/images/class/PreviousDayCommandClass.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/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.
4 changes: 2 additions & 2 deletions src/main/java/seedu/cafectrl/command/AddOrderCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public class AddOrderCommand extends Command {
+ "Example: " + COMMAND_WORD
+ "name/chicken rice qty/2";

protected Ui ui;
protected Pantry pantry;
protected OrderList orderList;
protected Menu menu;
private final Ui ui;
private final Order order;

Order order;
public AddOrderCommand(Order order, Ui ui, Pantry pantry, OrderList orderList, Menu menu) {
this.order = order;
this.ui = ui;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/cafectrl/command/ListMenuCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class ListMenuCommand extends Command {
+ COMMAND_WORD;
private static final DecimalFormat dollarValue = new DecimalFormat("0.00");

protected Menu menu;
protected Ui ui;
private final Menu menu;
private final Ui ui;

/**
* Constructor for the ListMenuCommand
Expand Down

0 comments on commit ff6892e

Please sign in to comment.