Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T3A4][T17-A3]Sin Yu Fan #1648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/seedu/addressbook/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ private void recordResult(CommandResult result) {
private CommandResult executeCommand(Command command) {
try {
command.setData(addressBook, lastShownList);
if(!storage.fileExists()) {
ui.showFileDoesNotExistMessage(storage.getPath());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation problem here?. Our coding standard requires you to use 4 spaces instead of tabs. You can configure Eclipse to convert tabs to spaces automatically.

}
CommandResult result = command.execute();
storage.save(addressBook);
return result;
Expand Down
4 changes: 4 additions & 0 deletions src/seedu/addressbook/storage/StorageFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,8 @@ public String getPath() {
return path.toString();
}

public boolean fileExists() {
return path.toFile().exists();
}

}
5 changes: 5 additions & 0 deletions src/seedu/addressbook/ui/TextUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,9 @@ private static String getIndexedListItem(int visibleIndex, String listItem) {
return String.format(MESSAGE_INDEXED_LIST_ITEM, visibleIndex, listItem);
}

public void showFileDoesNotExistMessage(String path) {
showToUser("File has been deleted, creating new file at " + path);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic string here. Should instead set it as a static final string.


}

}