forked from nusCS2113-AY1920S1/duke
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update FindOrderByDate class, add PostponeOrder class, delete StartNe…
…wOrder class, update methods in Parser for parsing order commands.
- Loading branch information
Yu Jiahan
committed
Oct 16, 2019
1 parent
710e4b0
commit 61a3f68
Showing
4 changed files
with
55 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package duke.orderCommand; | ||
|
||
import duke.command.Command; | ||
import duke.exception.DukeException; | ||
import duke.parser.Convert; | ||
import duke.storage.Storage; | ||
import duke.order.OrderList; | ||
import duke.ui.Ui; | ||
|
||
import java.util.Date; | ||
|
||
public class PostponeOrder extends OrderCommand { | ||
|
||
private int orderNb; | ||
private String until; | ||
private Date date; | ||
|
||
/** | ||
* The constructor method for snooze. | ||
* | ||
* @param orderNb order number | ||
* @param until snooze until when | ||
*/ | ||
public PostponeOrder(int orderNb, String until) { | ||
this.orderNb = orderNb; | ||
this.until = until; | ||
this.date = Convert.stringToDate(until); | ||
} | ||
|
||
@Override | ||
public void execute(OrderList orderList, Ui ui, Storage storage) throws DukeException { | ||
if (orderNb < orderList.size() && orderNb >= 0) { | ||
if (orderList.getOrder(orderNb).isDone()) { | ||
throw new DukeException("Seems like you've already finished that order, no need to snooze it now"); | ||
} | ||
orderList.changeOrderDate(orderNb, until); | ||
ui.showChangedDate(Convert.getDateString(date, until),orderList.getOrder(orderNb).toString()); | ||
storage.changeContent(orderNb); | ||
} else { | ||
throw new DukeException("Enter a valid order number after snooze, between 1 and " + orderList.size()); | ||
} | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters