Skip to content

Commit

Permalink
Shift data.txt into lib folder for better deployment of jar files
Browse files Browse the repository at this point in the history
  • Loading branch information
terrytay committed Feb 17, 2020
1 parent d299071 commit 40aa19a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
todo eat
false
event drink /at home
false
3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: duke.Duke

8 changes: 4 additions & 4 deletions src/main/java/duke/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Data {

public Data() throws FileNotFoundException {
this.todos = new ArrayList<Todo>();
File f = new File("src/main/java/duke/data.txt");
File f = new File("lib/data.txt");


// Adapted from https://nus-cs2113-ay1920s2.github.io/website/schedule/week6/topics.html
Expand Down Expand Up @@ -59,10 +59,10 @@ public static void newTask(String cmd) throws DukeException {
if (cmd.isEmpty()) {
throw new DukeException("Please type something.");
}
if (cmd.substring(0, 6).equals("delete")) {
todos.remove(Integer.parseInt(cmd.substring(cmd.indexOf(" ")+1))-1);
if (cmd.contains("delete")) {
System.out.println(" Noted. I've removed this task:");
System.out.println(" " + todos.get(getSize() - 1));
todos.remove(Integer.parseInt(cmd.substring(cmd.indexOf(" ")+1))-1);
System.out.println(" Now you have " + getSize() + " tasks in the list.");
} else {
if (!cmd.contains(" ") && cmd.length() > 0) {
Expand Down Expand Up @@ -124,7 +124,7 @@ public String getDescription(int i) {
return todos.get(i).getDescription();
}
public void saveToFile() throws IOException {
FileWriter fw = new FileWriter("src/main/java/duke/data.txt");
FileWriter fw = new FileWriter("lib/data.txt");
for (Todo todo : todos) {
String description = todo.getDescription();
boolean isDone = todo.isItDone();
Expand Down

0 comments on commit 40aa19a

Please sign in to comment.