Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code to bring user back to latest date accessed #261

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/CafeCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public class CafeCtrl {
private CafeCtrl() {
this.ui = new Ui();
this.storage = new Storage(this.ui);
this.currentDate = new CurrentDate();
this.sales = new Sales();
this.menu = this.storage.loadMenu();
this.pantry = this.storage.loadPantryStock();
this.sales = this.storage.loadOrderList(menu);
this.currentDate = new CurrentDate(sales);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/seedu/cafectrl/data/CurrentDate.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package seedu.cafectrl.data;

import java.util.ArrayList;

public class CurrentDate {
private int currentDay;

public CurrentDate() {
currentDay = 0;
}
public CurrentDate(Sales sales) {
setDate(sales);
}

public void nextDay() {
currentDay += 1;
Expand All @@ -18,4 +23,15 @@ public void previousDay() {
public int getCurrentDay() {
return currentDay;
}

/**
* Sets the current date to the latest date the user left off
*
* @param sales Used to access the number of orderlist created
*/
public void setDate(Sales sales) {
ArrayList<OrderList> orderLists = sales.getOrderLists();
int orderListsSize = orderLists.size();
currentDay = orderListsSize - 1;
}
}