-
Notifications
You must be signed in to change notification settings - Fork 228
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
[Jacob-109] iP #234
base: master
Are you sure you want to change the base?
[Jacob-109] iP #234
Changes from 2 commits
271e2f4
9522d74
082e99c
56d2f18
5b6adf0
0e6d2c7
b4d0ca6
91ba5b7
28f54b8
44c3b6d
81367c5
7e03915
3166da9
436656a
5a03f8f
5220f22
14de94b
0305fd6
9d38c53
76fb6d6
9337ccb
7301499
d7889df
bf4797e
05a3f62
c2d76ad
7d82d76
04b7f4d
f8c8bea
876e9ec
08f29a1
a82c13b
6cbdfba
4211cd9
afe7462
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
public class Deadline extends Task { | ||
|
||
protected String by; | ||
protected LocalDate date; | ||
|
||
public Deadline(String description, String by) { | ||
public Deadline(String description, LocalDate date) { | ||
super(description); | ||
this.by = by; | ||
this.date = date; | ||
} | ||
|
||
public String getBy() { | ||
return this.by; | ||
public LocalDate getBy() { | ||
return this.date; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[D]" + super.toString() + " (by: " + by + ")"; | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd yyyy"); | ||
return "[D]" + super.toString() + " (by: " + date.format(formatter) + ")"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,8 @@ | |
import java.io.IOException; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.Files; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
|
||
public class Duke { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it be better to add javadoc to all public classes and methods? The same applies to all other public classes and methods. |
||
|
@@ -34,7 +32,8 @@ private static void loadTasks(ArrayList<Task> list, File f) throws IOException { | |
String[] strArray = s.split("\\|", 4); | ||
|
||
if (strArray[0].trim().equals("D")) { | ||
Deadline deadline = new Deadline(strArray[2].trim(), strArray[3].trim()); | ||
LocalDate date =LocalDate.parse(strArray[3].trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd")); | ||
Deadline deadline = new Deadline(strArray[2].trim(), date); | ||
if (strArray[1].trim().equals("done")) { | ||
deadline.isDone = true; | ||
} else if (strArray[1].trim().equals("not done")){ | ||
|
@@ -61,6 +60,8 @@ private static void loadTasks(ArrayList<Task> list, File f) throws IOException { | |
} | ||
} | ||
|
||
|
||
|
||
public static void main(String[] args) throws DukeException{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should catch the DukeException, if not your program would stop running due to the exception. |
||
File file = new File("data/DukeData.txt"); | ||
File dir = new File("data/"); | ||
|
@@ -131,9 +132,10 @@ public static void main(String[] args) throws DukeException{ | |
System.out.println("Got it. I've added this task: "); | ||
System.out.println(e.toString()); | ||
} else if (word.contains("deadline")) { | ||
String[] input = word.split("/by"); | ||
String[] input = word.split("/by "); | ||
input[0] = input[0].replaceAll("deadline", ""); | ||
Deadline d = new Deadline(input[0], input[1]); | ||
LocalDate date =LocalDate.parse(input[1], DateTimeFormatter.ofPattern("yyyy-MM-dd")); | ||
Deadline d = new Deadline(input[0], date); | ||
list.add(d); | ||
System.out.println("Got it. I've added this task: "); | ||
System.out.println(d.toString()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the class be added or grouped inside a package? This applies to other classes as well.