Skip to content

Commit

Permalink
Merge branch 'master' into branch-A-CodingStandard
Browse files Browse the repository at this point in the history
  • Loading branch information
QianChangru committed Sep 10, 2023
2 parents 8ac5391 + 98baa49 commit cb8b5d6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/duke/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import java.time.format.DateTimeFormatter;
import java.util.Locale;


/**
* Encapsulates deadline which are Tasks with start and end.
*/
public class Deadline extends Task {
private LocalDate by;
public Deadline(String description, LocalDate by) {
Expand All @@ -22,6 +26,9 @@ public String toString() {
+ this.by.format(DateTimeFormatter.ofPattern("MMM dd yyyy", Locale.ENGLISH)) + ")";
}

/**
* Returns a String representation of the task for storage.
*/
@Override
public String toTxt() {
return "D | " + super.toTxt()
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/duke/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import java.time.format.DateTimeFormatter;
import java.util.Locale;

/**
* Encapsulates events which are Tasks with start and end.
*/
public class Event extends Task{
private LocalDate startTime;
private LocalDate endTime;
Expand All @@ -25,6 +28,9 @@ public String toString() {
+ " to: " + endTime.format(DateTimeFormatter.ofPattern("MMM dd yyyy", Locale.ENGLISH)) + ")";
}

/**
* Returns a String representation of the task for storage.
*/
@Override
public String toTxt() {
return "E | " + super.toTxt() + " | " + this.startTime.format(DateTimeFormatter.ofPattern("MMM dd yyyy", Locale.ENGLISH))
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/duke/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.time.LocalDate;

/**
* Parses the user input.
*/
public class Parser {
private String command;
private Storage storage;
Expand All @@ -14,6 +17,9 @@ public Parser(String command, Storage storage, TaskList taskList) {
this.taskList = taskList;
}

/**
* Parses the user input and initiate following operations.
*/
public void parse() {
try{
if (command.startsWith("list")) {
Expand Down Expand Up @@ -51,6 +57,9 @@ public void parse() {
}
}

/**
* Returns if the parser is ended.
*/
public boolean isEnd() {
return this.isEnd;
}
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/duke/Task.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package duke;

/**
* Encapsulates tasks for the chatbot.
*/
public class Task {
protected String description;
protected boolean isDone;

/**
* Constructs a new Task object.
*
* @param description Description of the task.
*/
public Task(String description) {
this.description = description;
this.isDone = false;
Expand All @@ -14,10 +22,17 @@ public Task(String description, boolean isDone) {
this.isDone = isDone;
}

/**
* Gets the status Icon of the Task.
*/
public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
// X for done task
return (isDone ? "X" : " ");
}

/**
* Marks the task as done.
*/
public void markAsDone() {
this.isDone = true;
}
Expand All @@ -27,6 +42,9 @@ public String toString() {
return "[" + this.getStatusIcon() + "] " + this.description;
}

/**
* Returns a String representation of the task for storage.
*/
public String toTxt() {
return (this.isDone ? "1" : "0") + " | " + this.description;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/duke/ToDo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package duke;

/**
* Encapsulates todos which are Tasks.
*/
public class ToDo extends Task {
public ToDo(String description) {
super(description);
Expand All @@ -14,6 +17,9 @@ public String toString() {
return "[T]" + super.toString();
}

/**
* Returns a String representation of the task for storage.
*/
@Override
public String toTxt() {
return "T | " + super.toTxt();
Expand Down

0 comments on commit cb8b5d6

Please sign in to comment.