forked from AY2425S1-CS2103T-T12-4/tp
-
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.
Merge pull request AY2425S1-CS2103T-T12-4#121 from JJtan2002/save-and…
…-load Implement save and load commands
- Loading branch information
Showing
24 changed files
with
224 additions
and
44 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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/seedu/address/logic/commands/LoadCommand.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,14 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
/** | ||
* Load command that will set address book to the saved file. | ||
*/ | ||
public class LoadCommand extends Command { | ||
public static final String COMMAND_WORD = "load"; | ||
public static final String MESSAGE_SUCCESS = "The saved address book has been loaded!"; | ||
public CommandResult execute(Model model) throws CommandException { | ||
return new CommandResult(MESSAGE_SUCCESS, false, false, false, true); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/seedu/address/logic/commands/SaveCommand.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,15 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
|
||
/** | ||
* Save command that saves the address book state to a save file. | ||
*/ | ||
public class SaveCommand extends Command { | ||
public static final String COMMAND_WORD = "save"; | ||
public static final String MESSAGE_SUCCESS = "Address book has been saved!"; | ||
public CommandResult execute(Model model) throws CommandException { | ||
return new CommandResult(MESSAGE_SUCCESS, false, false, true, false); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/seedu/address/model/VersionedAddressBook.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,29 @@ | ||
package seedu.address.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* {@code AddressBook} that tracks its state across command executions | ||
*/ | ||
public class VersionedAddressBook extends AddressBook { | ||
private final List<ReadOnlyAddressBook> addressBookStates; | ||
private int currentStatePointer; | ||
|
||
/** | ||
* Constructs a {@code VersionedAddressBook} with the initial state of the address book. | ||
* The address book will start with the specified initial state and the current state pointer | ||
* will be set to the initial state. | ||
* | ||
* @param initialState The initial state of the address book to be used as the starting point. | ||
* Cannot be null. | ||
*/ | ||
public VersionedAddressBook(ReadOnlyAddressBook initialState) { | ||
super(initialState); | ||
|
||
addressBookStates = new ArrayList<>(); | ||
addressBookStates.add(new AddressBook(initialState)); | ||
currentStatePointer = 0; | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.