Skip to content

Commit

Permalink
Made some of the class variables private
Browse files Browse the repository at this point in the history
  • Loading branch information
harryleecp committed Sep 24, 2020
1 parent c41783d commit ece93f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/tasks/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Lee Chein Pong Harry
*/
public class Deadline extends Task implements DateAndTime{
public String dueDate;
private String dueDate;

public Deadline(String description, String doBy) {
super(description.substring(9));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tasks/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
public class Event extends Task implements DateAndTime {

public String dueDate;
private String dueDate;

public Event(String description, String doAt) {
super(description.substring(6));
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* @author Lee Chein Pong Harry
*/
public abstract class Task {
public String task;
public boolean isDone;
private String task;
private boolean isDone;

public abstract String getTaskType();
public abstract String getDueDate();
Expand All @@ -26,6 +26,10 @@ public void setDone () {
this.isDone = true;
}

public boolean getIsDone() {
return isDone;
}

public String printTask() {
String mark = "";
if (this.isDone) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/userInterface/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public void saveTextFile(ArrayList<Task> tasks) throws IOException {
FileWriter fw = new FileWriter(filename);
String textToWrite = "";
for (Task item : tasks) {
String doneIndex = (item.isDone) ? "1" : "0";
String doneIndex = (item.getIsDone()) ? "1" : "0";
if (item.getTaskType().equals("T")) {
textToWrite += "T | " + doneIndex + " | " + item.task + "\n";
textToWrite += "T | " + doneIndex + " | " + item.getTask() + "\n";
} else {
//Deadline and Event class objects have due dates
textToWrite += item.getTaskType() + " | " + doneIndex + " | "+ item.task + " | " + item.getDueDate() + "\n";
textToWrite += item.getTaskType() + " | " + doneIndex + " | "+ item.getTask() + " | " + item.getDueDate() + "\n";
}
}
fw.write(textToWrite);
Expand Down

0 comments on commit ece93f8

Please sign in to comment.