forked from nusCS2113-AY1819S1/addressbook-level3
-
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.
WriteNotification class created - write to text file
- Loading branch information
1 parent
ee1b4b6
commit 37e96eb
Showing
6 changed files
with
74 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package seedu.addressbook.inbox; | ||
|
||
public class NotificationManager { | ||
} |
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,4 @@ | ||
package seedu.addressbook.inbox; | ||
|
||
public class ReadNotification { | ||
} |
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 seedu.addressbook.inbox; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
public class WriteNotification { | ||
private String path; | ||
private boolean isAppend = false; | ||
|
||
public WriteNotification(String filePath){ | ||
path = filePath; | ||
} | ||
|
||
public WriteNotification(String filePath, boolean appendValue){ | ||
path = filePath; | ||
isAppend = appendValue; | ||
} | ||
|
||
|
||
/** Message format should look like this | ||
* Read/Unread (1 or 0) --> for writeToFile function, messages are entered as unread. | ||
* Priority of Message | ||
* Timestamp of message | ||
* Message | ||
* ETA, if applicable | ||
* Location, if available | ||
*/ | ||
|
||
public void writeToFile(Msg message) throws IOException{ | ||
FileWriter write = new FileWriter (path, isAppend); | ||
PrintWriter myPrinter = new PrintWriter(write); | ||
myPrinter.println(message.isRead); | ||
myPrinter.println(message.getPriority()); | ||
myPrinter.println(message.getTime()); | ||
myPrinter.println(message.getMsg()); | ||
if(message.hasEta()) | ||
myPrinter.println(message.getEta()); | ||
if(message.isLocationAvailable) { | ||
myPrinter.println(message.getLatitude()); | ||
myPrinter.println(message.getLongitude()); | ||
} | ||
myPrinter.println("---"); // Notate the end of 1 message entry with "---" | ||
myPrinter.close(); | ||
} | ||
|
||
} |
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