Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
876151e
Add level 0 increment
irfandeen Jan 21, 2025
e614df3
Remove unused variables in WallE.java
irfandeen Jan 21, 2025
bf9e4bd
Add echo command functionality
irfandeen Feb 2, 2025
290ffb1
Add list to store and list out tasks
irfandeen Feb 2, 2025
90a643a
Add mark and unmark functionality to task list
irfandeen Feb 2, 2025
827efec
Create Task class to represent tasks
irfandeen Feb 2, 2025
7fec201
Modify code to adhere to coding standard
irfandeen Feb 2, 2025
b578e77
Add subclasses extending Task class
irfandeen Feb 11, 2025
a2e877e
Add toString() method to base class
irfandeen Feb 11, 2025
9c6ad3e
Refactor WallE class to improve readability
irfandeen Feb 11, 2025
46c910b
Add try catch for all exceptions
irfandeen Feb 15, 2025
39abee7
Fix toString() methods
irfandeen Feb 15, 2025
1918418
Add error handling
irfandeen Feb 15, 2025
cbafecb
Merge branch 'branch-Level-5'
irfandeen Feb 15, 2025
6578450
Add Wall-E Exception class
irfandeen Feb 15, 2025
5ca2ee5
Refactor code into Wall-E package
irfandeen Feb 15, 2025
03306fb
feature: allow multi-word dates for events and deadlines
irfandeen Feb 21, 2025
bba9299
Refactor Task array into ArrayList for dynamic access
irfandeen Feb 21, 2025
e601a9f
Add delete task functionality
irfandeen Feb 21, 2025
43d21ea
Add file parser. Processing file parser output TBC
irfandeen Feb 22, 2025
45037e0
feature: persistence with text file
irfandeen Feb 22, 2025
34ff431
Merge branch 'branch-Level-6'
irfandeen Feb 22, 2025
0aec5e3
Resolve merge conflicts
irfandeen Feb 22, 2025
43b40c8
Fix bugs arising from ArrayList access
irfandeen Feb 22, 2025
e0c8602
Add JAR manifest
irfandeen Feb 22, 2025
543da72
Refactor to be more modularized. Full functionality not yet restored.
irfandeen Mar 6, 2025
31afe02
Refactor complete. Fully functional and modularized
irfandeen Mar 6, 2025
9e75e32
Add date time functionality to deadline
irfandeen Mar 7, 2025
da8b95b
Fix code style nit
irfandeen Mar 7, 2025
fe47074
Add find functionality to WallE
irfandeen Mar 7, 2025
e6338cd
Add JavaDoc comments for public methods and classes.
irfandeen Mar 7, 2025
826535c
Merge pull request #1 from irfandeen/branch-Level-8
irfandeen Mar 7, 2025
bff51c2
Resolve conflicts between Find functionality and DateTime functionality
irfandeen Mar 7, 2025
0f2aa02
Merge pull request #2 from irfandeen/branch-Level-9
irfandeen Mar 7, 2025
300372a
Resolve conflicts between master and JavaDoc branch
irfandeen Mar 7, 2025
a1a16ed
Merge pull request #3 from irfandeen/branch-A-JavaDoc
irfandeen Mar 7, 2025
d13d5bd
Add Readme.md
irfandeen Mar 7, 2025
a106526
Fix bugs with deadline command
irfandeen Mar 12, 2025
642d36b
Add input into UserInterface class
irfandeen Mar 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# WallE project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 17, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 17** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
1. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
1. After that, locate the `src/main/java/WallE.java` file, right-click it, and choose `Run WallE.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand Down
4 changes: 4 additions & 0 deletions data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0,T,hi
1,T,bye
1,E,seminar,4pm,6pm
0,D,push commits,today 4pm
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke User Guide
# WallE User Guide

// Update the title above to match the actual product name

Expand Down
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

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: walle.WallE

28 changes: 28 additions & 0 deletions src/main/java/walle/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package walle;

public class Deadline extends Task {
protected String dueDate;

public Deadline(String description, String dueDate) {
super(description);
this.dueDate = dueDate;
}

@Override
public String getType() {
return "[D]";
}

public String getTypeIcon() {
return "D";
}

public String getDueDate() {
return dueDate;
}

@Override
public String toString() {
return super.toString() + " (by: " + dueDate + ")";
}
}
34 changes: 34 additions & 0 deletions src/main/java/walle/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package walle;

public class Event extends Task {
protected String startDate;
protected String endDate;

public Event(String description, String startDate, String endDate) {
super(description);
this.startDate = startDate;
this.endDate = endDate;
}

@Override
public String getType() {
return "[E]";
}

public String getTypeIcon() {
return "E";
}

public String getStartDate() {
return startDate;
}

public String getEndDate() {
return endDate;
}

@Override
public String toString() {
return super.toString() + " (from: " + startDate + ", to: " + endDate + ")";
}
}
92 changes: 92 additions & 0 deletions src/main/java/walle/FileParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package walle;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class FileParser {
public static int readFileContents(String filePath, ArrayList<Task> tasks) throws FileNotFoundException {
File f = new File(filePath);
Scanner s = new Scanner(f);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using more intuitive naming, f and s do not explain what the variables entail.

int listSize = 0;
while (s.hasNext()) {
String[] taskString = s.nextLine().split(",");
boolean isDone = taskString[0].equals("1") ? true : false;
String taskType = taskString[1];
String taskDescription = taskString[2];

if (taskType.equals("T")) {
tasks.add(new Todo(taskDescription));
} else if (taskType.equals("D")) {
String dueDate = taskString[3];
tasks.add(new Deadline(taskDescription, dueDate));
} else if (taskType.equals("E")) {
String fromDate = taskString[3];
String toDate = taskString[4];
tasks.add(new Event(taskDescription, fromDate, toDate));
}

if (isDone) {
tasks.get(listSize).markAsDone();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many magic literals here, consider using constants instead or if not possible, then add some concise comments on what is happening here.


listSize++;
}
s.close();
return listSize;
}

private static void createFile(String filePath) {
try {
File f = new File(filePath);
if (f.createNewFile()) {
System.out.println("File created: " + f.getName());
FileWriter writer = new FileWriter(f);
writer.close();
} else {
System.out.println("File already exists.");
}
} catch (IOException e) {
System.out.println("An error occurred while creating the file.");
}
}

public FileParser(String filePath) {
File f = new File(filePath);
if (!f.exists()) {
createFile(filePath);
}
}

public void saveToFile(String filePath, ArrayList<Task> tasks, int listSize) {
File f = new File(filePath);
if (!f.exists()) {
createFile(filePath);
}

try {
FileWriter writer = new FileWriter(f);
for (int i = 0; i < listSize; i++) {
Task t = tasks.get(i);
String status = t.isDone() ? "1" : "0";
writer.write(status + "," + t.getTypeIcon() + "," + t.getDescription());
if (t.getTypeIcon() == "T") {
writer.write("\n");
} else if (t.getTypeIcon() == "D") {
Deadline d = (Deadline) t;
writer.write("," + d.getDueDate() + "\n");
} else if (t.getTypeIcon() == "E") {
Event e = (Event) t;
writer.write("," + e.getStartDate() + "," + e.getEndDate() + "\n");
}
}
writer.close();
Comment on lines +70 to +
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is around 3 levels of indentation, consider refactoring the internal levels into another method.

} catch (Exception e) {
System.out.println("An error occurred while saving the file.");
System.out.println(e.getMessage());
}
}
}
44 changes: 44 additions & 0 deletions src/main/java/walle/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package walle;

public class Task {
protected String description;
protected boolean isDone;

public Task(String description) {
this.description = description;
this.isDone = false;
}

public String getStatusIcon() {
return (isDone ? "[X]" : "[ ]");
}

public void markAsDone() {
isDone = true;
}

public void unmarkAsDone() {
isDone = false;
}

public String getType() {
return "[ ]";
}

public String getTypeIcon() {
return " ";
}

public boolean isDone() {
return isDone;
}

public String getDescription() {
return description;
}

@Override
public String toString() {
return getType() + getStatusIcon() + " " + description;
}
}
16 changes: 16 additions & 0 deletions src/main/java/walle/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package walle;

public class Todo extends Task {
public Todo(String description) {
super(description);
}

@Override
public String getType() {
return "[T]";
}

public String getTypeIcon() {
return "T";
}
}
Loading