-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'sharedRepo/master' into master
- Loading branch information
Showing
46 changed files
with
896 additions
and
360 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ src/main/resources/docs/ | |
/.idea/ | ||
/out/ | ||
/*.iml | ||
*.iml | ||
|
||
# Storage/log files | ||
/data/ | ||
|
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
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
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
48 changes: 48 additions & 0 deletions
48
src/main/java/nustorage/logic/commands/DeleteFinanceCommand.java
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,48 @@ | ||
package nustorage.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Optional; | ||
|
||
import nustorage.commons.core.Messages; | ||
import nustorage.commons.core.index.Index; | ||
import nustorage.logic.commands.exceptions.CommandException; | ||
import nustorage.model.Model; | ||
import nustorage.model.record.FinanceRecord; | ||
|
||
/** | ||
* Deletes an existing finance record from the address book. | ||
*/ | ||
public class DeleteFinanceCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "delete_finance"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Deletes the finance record identified by the index number used in the finance list.\n" | ||
+ "Parameters: INDEX (must be a positive integer)\n" | ||
+ "Example: " + COMMAND_WORD + " 1"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Finance record deleted: %1$s"; | ||
|
||
private final Index targetIndex; | ||
|
||
/** | ||
* Creates an AddFinanceCommand to add the specified {@code Finance Record} | ||
*/ | ||
public DeleteFinanceCommand(Index targetIndex) { | ||
this.targetIndex = targetIndex; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
Optional<FinanceRecord> record = model.deleteFinanceRecord(targetIndex); | ||
|
||
if (record.isPresent()) { | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, record.get())); | ||
} else { | ||
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
} | ||
} | ||
} |
Oops, something went wrong.