forked from nusCS2113-AY1920S1/PersonalAssistant-Duke
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Araavinds/b-listtags
Adds new command to list based on tag. Resolves Issue #63
- Loading branch information
Showing
3 changed files
with
51 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package executor.command; | ||
|
||
import executor.task.TaskList; | ||
import interpreter.Parser; | ||
import ui.ReceiptTracker; | ||
import ui.Ui; | ||
import ui.Wallet; | ||
import java.text.DecimalFormat; | ||
|
||
public class CommandListTag extends CommandList { | ||
private String tag; | ||
|
||
//Constructor | ||
/** | ||
* Constructor for CommandListTag subCommand Class. | ||
* @param userInput The user input from the CLI | ||
*/ | ||
public CommandListTag(String userInput) { | ||
super(userInput); | ||
this.userInput = userInput; | ||
this.description = "Lists based on tag"; | ||
this.commandType = CommandType.TAGLIST; | ||
this.tag = Parser.parseForPrimaryInput(this.commandType, userInput); | ||
} | ||
|
||
@Override | ||
public void execute(TaskList taskList) { | ||
|
||
} | ||
|
||
@Override | ||
public void execute(Wallet wallet) { | ||
ReceiptTracker taggedReceipts = wallet.getReceipts().findReceiptsByTag(this.tag); | ||
DecimalFormat decimalFormat = new DecimalFormat("#0.00"); | ||
Ui.dukeSays("You spent a total of $" | ||
+ | ||
decimalFormat.format(taggedReceipts.getTotalCashSpent()) | ||
+ " " | ||
+ "on" | ||
+ " " | ||
+ tag | ||
); | ||
Ui.printSeparator(); | ||
taggedReceipts.printReceipts(); | ||
Ui.printSeparator(); | ||
} | ||
} |
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