File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,10 +12,19 @@ public class Parser {
1212 + "What can I do for you today?" ;
1313 private static String farewell = "Goodbye, have a good day." ;
1414 private TaskList tasks ;
15+
16+ /**
17+ * Returns a new Parser object with the given list of tasks.
18+ * @param tasks Current list of tasks.
19+ */
1520 public Parser (TaskList tasks ) {
1621 this .tasks = tasks ;
1722 }
1823
24+ /**
25+ * Reads and executes commands given by user.
26+ * @throws JarvisException if command entered is not recognised.
27+ */
1928 public void readCommand () throws JarvisException {
2029 while (true ) {
2130 //receive user input
@@ -113,10 +122,16 @@ public void readCommand() throws JarvisException {
113122 }
114123 }
115124
125+ /**
126+ * Prints Introduction message.
127+ */
116128 public void introduction () {
117129 System .out .println (introduction );
118130 }
119131
132+ /**
133+ * Prints farewell message.
134+ */
120135 public void farewell () {
121136 System .out .print (farewell );
122137 }
Original file line number Diff line number Diff line change 1010import java .util .Scanner ;
1111public class Storage {
1212 private String filePath ;
13+
14+ /**
15+ * Return new Storage Object with the specified filePath of data.
16+ * @param filePath Specified file path of data stored.
17+ */
1318 public Storage (String filePath ) {
1419 this .filePath = filePath ;
1520 }
21+
22+ /**
23+ * Loads tasks from data file into a task list.
24+ * @return List of tasks.
25+ * @throws IOException if error occurs when reading file.
26+ */
1627 public List <Task > load () throws IOException {
1728 File myFile = new File (filePath );
1829 List <Task > taskList = new ArrayList <>();
@@ -54,6 +65,11 @@ public List<Task> load() throws IOException {
5465 return taskList ;
5566 }
5667
68+ /**
69+ * Stores task list in data file in given file path.
70+ * @param tasks Task List to be stored.
71+ * @throws IOException if error occurs when writing to data file.
72+ */
5773 public void write (TaskList tasks ) throws IOException {
5874 File myFile = new File (filePath );
5975 myFile .createNewFile ();
Original file line number Diff line number Diff line change 33import java .time .LocalDate ;
44import java .time .format .DateTimeFormatter ;
55
6+ /**
7+ * Represents a Deadline which is a subclass of Task.
8+ *
9+ */
610public class Deadline extends Task {
711 public LocalDate by ;
812
13+ /**
14+ * Returns a new Deadline Object with the given description and date.
15+ *
16+ * @param description Description of the task to be done by deadline.
17+ * @param date Date of the Deadline.
18+ */
919 public Deadline (String description , String date ) {
1020 super (description );
1121 this .by = LocalDate .parse (date );
1222 }
1323
24+ /**
25+ * Returns String description of Deadline in the following format:
26+ * [D] *Deadline Description* (by: *date*)
27+ * @return String description of Deadline.
28+ */
1429 @ Override
1530 public String toString () {
1631 return "[D]" + super .toString () + " (by: " + by .format (DateTimeFormatter .ofPattern ("MMM d yyyy" )) + ")" ;
Original file line number Diff line number Diff line change 33import java .time .LocalDate ;
44import java .time .format .DateTimeFormatter ;
55
6+ /**
7+ * Represents an Event which is a subclass of Task.
8+ *
9+ */
610public class Event extends Task {
711
812 public LocalDate at ;
913
14+ /**
15+ * Returns a new Event Object with the given description and date.
16+ *
17+ * @param description Description of the Event.
18+ * @param date Date of the Event.
19+ */
1020 public Event (String description , String date ) {
1121 super (description );
1222 this .at = LocalDate .parse (date );
1323 }
1424
25+ /**
26+ * Returns String description of Deadline in the following format:
27+ * [E] *Event Description* (at: *date*)
28+ * @return String description of Event.
29+ */
1530 @ Override
1631 public String toString () {
1732 return "[E]" + super .toString () + " (at: " + at .format (DateTimeFormatter .ofPattern ("MMM d yyyy" )) + ")" ;
Original file line number Diff line number Diff line change 11package jarvis .task ;
22
3- public class Task {
3+ /**
4+ * Represents a Task.
5+ */
6+ public abstract class Task {
47 public String description ;
58 public boolean isDone ;
69
710 public static int count = 0 ;
811
12+ /**
13+ * Returns a Task object with the given Description.
14+ *
15+ * @param description Description of the task.
16+ */
917 public Task (String description ) {
1018 this .description = description ;
1119 this .isDone = false ;
1220 count ++;
1321
1422 }
1523
24+ /**
25+ * Marks the task as done.
26+ */
1627 public void mark (){
1728 isDone = true ;
1829 }
1930
31+ /**
32+ * Marks the task as not done
33+ */
2034 public void unmark () {
2135 isDone = false ;
2236 }
2337
38+ /**
39+ * Get done/undone status of task
40+ * @return "X" if done, " " if not done
41+ */
2442 public String getStatusIcon () {
2543 return (isDone ? "X" : " " ); // mark done task with X
2644 }
2745
46+ /**
47+ * @return String description of Task.
48+ */
2849 @ Override
2950 public String toString () {
3051 return "[" + getStatusIcon () + "] " + this .description ;
Original file line number Diff line number Diff line change 33import java .util .ArrayList ;
44import java .util .List ;
55
6+ /**
7+ * Represents a list of Tasks
8+ */
69public class TaskList {
710 private List <Task > tasks ;
811
12+ /**
13+ * Returns a TaskList object with the given tasks
14+ *
15+ * @param tasks Initial List of tasks
16+ */
917 public TaskList (List <Task > tasks ) {
1018 this .tasks = tasks ;
1119 }
1220
21+ /**
22+ * Returns an empty TaskList object
23+ */
1324 public TaskList () {
1425 this .tasks = new ArrayList <>();
1526 }
1627
28+ /**
29+ * @return List of tasks
30+ */
1731 public List <Task > getList () {
1832 return tasks ;
1933 }
Original file line number Diff line number Diff line change 11package jarvis .task ;
22
3+ /**
4+ * Represents a ToDo which is a subclass of Task.
5+ *
6+ */
37public class ToDo extends Task {
48
9+ /**
10+ * Returns a new Todo Object with the given description.
11+ *
12+ * @param description Description of the ToDo task.
13+ */
514 public ToDo (String description ) {
615 super (description );
716 }
817
18+ /**
19+ * Returns String description of Deadline in the following format:
20+ * [T] *ToDo Description*
21+ * @return String description of ToDo.
22+ */
923 @ Override
1024 public String toString () {
1125 return "[T]" + super .toString ();
You can’t perform that action at this time.
0 commit comments