Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
eeda7cd
Level-0: Implemented Rename, Greet and Exit
adithyamangalam03 Sep 3, 2024
3dbc7ed
Level-1: Implemented Echo
adithyamangalam03 Sep 3, 2024
3545f8f
Level-2: Implemented Add & List
adithyamangalam03 Sep 4, 2024
c5937a0
Level-3: Implemented Mark/Unmark function for tasks
adithyamangalam03 Sep 4, 2024
a7ed3ec
Level-4: Implemented ToDo, Deadline & Event Functionality
adithyamangalam03 Sep 4, 2024
3c2e5a2
Level-4: Deadline output changed to omit 'deadline'
adithyamangalam03 Sep 5, 2024
f0acaa3
branch-Level-5: Added FlashException Class
adithyamangalam03 Sep 12, 2024
cc00e52
branch-Level-5: Added error handling to todo
adithyamangalam03 Sep 12, 2024
8e5f97c
Added error handling for event
adithyamangalam03 Sep 12, 2024
fad3efb
Added error handling for deadline
adithyamangalam03 Sep 12, 2024
2316c0b
Level-5: Implemented FlashException for error handling
adithyamangalam03 Sep 12, 2024
456b24b
Merge branch 'branch-Level-5'
adithyamangalam03 Sep 12, 2024
811769c
Implemented delete task function in branch-Level-6
adithyamangalam03 Oct 2, 2024
d05b803
Implemented new function for Level-7
adithyamangalam03 Oct 3, 2024
9024ae5
Merge branch 'branch-Level-6'
adithyamangalam03 Oct 3, 2024
febbce1
Merge branch 'branch-Level-7'
adithyamangalam03 Oct 3, 2024
8514320
Added exception handling for deleteTask with no task number
adithyamangalam03 Oct 4, 2024
63d3acc
Move task related classes into task package
adithyamangalam03 Oct 11, 2024
0d4b146
Refactor UI methods to UI class
adithyamangalam03 Oct 11, 2024
4ca10de
Move parsing methods to Parser class
adithyamangalam03 Oct 11, 2024
e340a54
Move methods on task list to TaskList class
adithyamangalam03 Oct 11, 2024
bbb61c9
Merge branch 'branch-A-MoreOOP'
adithyamangalam03 Oct 11, 2024
94d3b6e
Implement find function (level 9)
adithyamangalam03 Oct 11, 2024
60e059c
Merge branch 'branch-Level-9'
adithyamangalam03 Oct 11, 2024
a91164f
Add JavaDoc to all methods and classes
adithyamangalam03 Oct 11, 2024
2ef672d
Merge branch 'branch-A-JavaDoc'
adithyamangalam03 Oct 11, 2024
9474427
Add UserGuide
adithyamangalam03 Oct 11, 2024
d246758
Merge branch 'branch-A-UserGuide'
adithyamangalam03 Oct 11, 2024
07ca321
Update README.md
adithyamangalam03 Oct 11, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ignore all class files
*.class

# IDEA files
/.idea/
/out/
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Deadline extends Task{
protected String by;

public Deadline(String description, String by) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

has proper use of inheritance and no noticeable formatting issues.

super(description);
this.by = by;
}

@Override
public String toString() {
return "[D]" + super.toString() + "(by: " + by + ")" ;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

proper use of overiding and with clear comments

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

This file was deleted.

15 changes: 15 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Event extends Task{
protected String from;
protected String to;

public Event(String description, String from, String to) {
super(description);
this.from = from;
this.to = 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.

proper use of overiding and with clear comments

@Override
public String toString() {
return "[E]" + super.toString() + "(from: " + from + " to: " + to + ")";
}
}
107 changes: 107 additions & 0 deletions src/main/java/Flash.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import java.sql.Array;
import java.util.Scanner;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

well done. code functionality is implemented with well organized methods and with naming that describes the purpose well, and is in camelCase. if else statement is also in egyptian format

import java.util.List;
import java.util.ArrayList;

public class Flash {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To improve abstraction, you can refactor the code by separating task-related logic from the main control flow. One class can handle the application's control logic (user interaction, commands) while another class can be responsible for managing tasks (adding, deleting, marking, saving, etc.).


private static final List<Task> tasks = new ArrayList<>();

public static void displayTasks() {
System.out.println("____________________________________________________________");
for(int i = 0; i < tasks.size(); i++) {
System.out.println(i+1 + "." + tasks.get(i));
}
System.out.println("____________________________________________________________");
}

public static void markTask(String input) {
int taskNumber = Integer.parseInt(input.split(" ")[1]) - 1;
Task task = tasks.get(taskNumber);
task.markDone();
System.out.println("____________________________________________________________");
System.out.println("Nice! I've marked this task as done:");
System.out.println(" " + task);
System.out.println("____________________________________________________________");
}

public static void unMarkTask(String input) {
int taskNumber = Integer.parseInt(input.split(" ")[1]) - 1;
Task task = tasks.get(taskNumber);
task.markNotDone();
System.out.println("____________________________________________________________");
System.out.println("Ok, I've marked this task as not done yet:");
System.out.println(" " + task);
System.out.println("____________________________________________________________");
}

public static void todo(String input){
String description = input.substring(5).trim();
Task task = new ToDo(description);
tasks.add(task);
System.out.println("____________________________________________________________");
System.out.println(" " + task);
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
System.out.println("____________________________________________________________");
}

public static void deadline(String input) {
String[] parts = input.substring(8).split(" /by ");
String description = parts[0].trim();
String by = parts[1].trim();
Task task = new Deadline(description, by);
tasks.add(task);
System.out.println("____________________________________________________________");
System.out.println("Got it. I've added this task:");
System.out.println(" " + task);
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
System.out.println("____________________________________________________________");
}

public static void event(String input) {
String[] parts = input.substring(6).split(" /from | /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.

Avoid using magic numbers like substring(6).split. Used named constants for these numbers instead.

String description = parts[0].trim();
String from = parts[1].trim();
String to = parts[2].trim();
Task task = new Event(description, from, to);
tasks.add(task);
System.out.println("____________________________________________________________");
System.out.println("Got it. I've added this task:");
System.out.println(" " + task);
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
System.out.println("____________________________________________________________");

}

public static void main(String[] args) {
Scanner in = new Scanner(System.in);

System.out.println("____________________________________________________________");
System.out.println(" Hello! I'm Flash");
System.out.println(" What can I do for you?");
System.out.println("____________________________________________________________");

String input;
while(true) {
input = in.nextLine();
if (input.equalsIgnoreCase("bye")) {
System.out.println("____________________________________________________________");
System.out.println("Bye. Hope to see you again soon!");
System.out.println("____________________________________________________________");
break;
} else if (input.equalsIgnoreCase("list")) {
displayTasks();
} else if (input.startsWith("mark")) {
markTask(input);
} else if (input.startsWith("unmark")){
unMarkTask(input);
} else if (input.startsWith("todo")) {
todo(input);
} else if (input.startsWith("deadline")) {
deadline(input);
} else if (input.startsWith("event")) {
event(input);
}
}
}
}
31 changes: 31 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
public class Task {
protected String description;
protected boolean isDone;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

well done. code has proper and regular formatting and is easily understood


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

public String getIcon() {
if (isDone) {
return "X";
} else {
return " ";
}
}

public void markDone() {
this.isDone = true;
}

public void markNotDone() {
this.isDone = false;
}

@Override
public String toString() {
return "[" + getIcon() + "]" + description;
}

}
11 changes: 11 additions & 0 deletions src/main/java/ToDo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class ToDo extends Task{

public ToDo(String description) {
super(description);
}

@Override
public String toString() {
return "[T]" + super.toString();
}
}