Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Denise-Ng committed Apr 9, 2020
1 parent 407e87a commit f0a04b4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/AboutUs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Responsibilities: Remind Feature of Coupon Stash

=== Denise Ng
image::denise-ng.png[width="150", align="left"]
{empty}[http://github.com/denise-ng[github]] [<<deniseng#, portfolio>>]
{empty}[http://github.com/denise-ng[github]] [<<denise-ng#, portfolio>>]

Role: Developer +
Responsibilities: Expiring, copy and goto features & calendar in Coupon Stash.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public CommandResult execute(Model model, String commandText) throws CommandExce
}

public String getCopiedString(Coupon coupon) {
assert coupon != null : "coupon should not be null";
Savings savings = coupon.getSavingsForEachUse();
String totalSavings = "";
if (savings.hasMonetaryAmount()) {
Expand All @@ -87,8 +88,7 @@ public String getCopiedString(Coupon coupon) {
conditionString = PREFIX_CONDITION + condition.value + " ";
}

String copyCommand = couponAsAddCommand(coupon, totalSavings, conditionString);
return copyCommand;
return couponAsAddCommand(coupon, totalSavings, conditionString);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ public class ExpiringCommand extends Command {
private final String date;

public ExpiringCommand(DateIsEqualsPredicate predicate) {
requireNonNull(predicate);
this.predicate = predicate;
this.date = predicate.getDate();
}

public ExpiringCommand(DateIsInMonthYearPredicate predicate) {
requireNonNull(predicate);
this.predicate = predicate;
this.date = predicate.getDate();
}
Expand All @@ -57,20 +59,13 @@ public CommandResult execute(Model model, String commandText) {

model.updateFilteredCouponList(predicate);
int filteredListSize = model.getFilteredCouponList().size();
if (filteredListSize > 0) {
if (DateUtil.isValidDate(date)) {
model.updateMonthView(DateUtil.formatDateStringToYearMonthString(date));
return new CommandResult(String.format(Messages.MESSAGE_COUPONS_EXPIRING_ON_DATE,
filteredListSize, date));
} else {
model.updateMonthView(date);
return new CommandResult(String.format(Messages.MESSAGE_COUPONS_EXPIRING_DURING_YEAR_MONTH,
filteredListSize, date));
}
} else { // Empty list
assert filteredListSize == 0 : "Filtered list should be empty.";
model.updateMonthView(DateUtil.formatYearMonthToString(YearMonth.now()));
return new CommandResult(String.format(Messages.MESSAGE_NO_COUPONS_EXPIRING, date));
if (DateUtil.isValidDate(date)) {
model.updateMonthView(DateUtil.formatDateStringToYearMonthString(date));
return new CommandResult(String.format(Messages.MESSAGE_COUPONS_EXPIRING_ON_DATE,filteredListSize, date));
} else {
model.updateMonthView(date);
return new CommandResult(String.format(Messages.MESSAGE_COUPONS_EXPIRING_DURING_YEAR_MONTH,
filteredListSize, date));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class GoToCommand extends Command {
private String value;

public GoToCommand(String yearMonth) {
requireNonNull(yearMonth);
this.value = yearMonth;
}

Expand Down
29 changes: 24 additions & 5 deletions src/main/java/csdev/couponstash/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class ListCommand extends Command {
+ COMMAND_WORD + " " + PREFIX_USAGE + " (used coupons list)\n";

private Prefix prefixToList;
private Views view;


public ListCommand() {
this.prefixToList = new Prefix("");
Expand All @@ -44,18 +46,18 @@ public ListCommand(Prefix prefixToList) {
public CommandResult execute(Model model, String commandText) {
requireNonNull(model);
model.updateMonthView(DateUtil.formatYearMonthToString(YearMonth.now()));
String view = "";

if (prefixToList.toString().isEmpty()) {
model.updateFilteredCouponList(Model.PREDICATE_SHOW_ALL_ACTIVE_COUPONS);
view = "active";
view = Views.ACTIVE;
} else if (prefixToList.equals(PREFIX_ARCHIVE)) {
model.updateFilteredCouponList(Model.PREDICATE_SHOW_ALL_ARCHIVED_COUPONS);
view = "archived";
view = Views.ARCHIVED;
} else if (prefixToList.equals(PREFIX_USAGE)) {
model.updateFilteredCouponList(Model.PREDICATE_SHOW_ALL_USED_COUPONS);
view = "used";
view = Views.USED;
}
return new CommandResult(String.format(MESSAGE_SUCCESS, view));
return new CommandResult(String.format(MESSAGE_SUCCESS, view.getView()));
}

@Override
Expand All @@ -74,4 +76,21 @@ public boolean equals(Object other) {
ListCommand e = (ListCommand) other;
return prefixToList.equals((e).prefixToList);
}


private enum Views {
ACTIVE ("active"),
ARCHIVED ("archived"),
USED ("used");

private final String view;

Views(String view) {
this.view = view;
}

String getView() {
return this.view;
}
}
}

0 comments on commit f0a04b4

Please sign in to comment.