Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

119 changes: 119 additions & 0 deletions src/main/java/bro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import java.util.Scanner;
import java.util.ArrayList;

public class bro {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The class name bro should follow Java naming conventions. Use PascalCase for class names. Consider renaming it to something more descriptive, like TaskManager or TaskApp.


private static final ArrayList<String> storer = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Have a better variable name. Can specify what 'storer' stores?

private static final ArrayList<String> mark_tracker = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could have use a seperate class for Tasks to track the info and marking


public static void level0() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did bro hard code level 0 ? 😭 Did not remove redundant function again.

System.out.println("Hello! I'm bro");
System.out.println("What can I do for you?");
System.out.println("Bye. Hope to see you again soon!");

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 line should not be here? The chatbot prints Bye almost instantly

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bye should not be in level 0

}

public static void echo() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did not remove redundant function that is no longer used.


String line;
Scanner in = new Scanner(System.in);
while (true) {
line = in.nextLine();

if (line.equals("Bye")) {
break;
}
System.out.println(line);
}

System.out.println("Bye. Hope to see you again soon!");

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 line is redundant. Needs to be displayed only when 'bye' is entered by user.


}

public static void addList() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use descriptive names for your methods. For example, addList could be renamed to manageTasks, as it implies that this method is responsible for task management

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The addList method is quite long. Break it down into smaller methods for each task type handling to improve readability and maintainability.


String line;
Scanner in = new Scanner(System.in);

while (true) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wait if you have while(true) loop in your addList and you call your mark only after addList, wouldnt you be marking after the user inputs bye.

line = in.nextLine();

if (line.equals("Bye")) {

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 strings directly in your code (e.g., "Bye", "list", "todo"). Instead, consider defining constants at the beginning of your class to improve readability and maintainability.

break;

} else if (line.equals("list")) {

// int tracker = 1;
// for (String item : storer) {
// String curr_tracker = Integer.toString(tracker);
// System.out.println(curr_tracker + ". " + item);
// tracker ++;

for (int i = 0; i < storer.size(); i++) {
System.out.println((i + 1) + ". " + storer.get(i));
}

} else {
storer.add(line);
}

}

System.out.println("Bye. Hope to see you again soon!");


}

public static void mark() {

// track if the current job is marked or unmarked
for (int i = 0; i < storer.size(); i++) {
// System.out.println((i + 1) + ". " + storer.get(i));
mark_tracker.add("[]");
}

String line;
Scanner in = new Scanner(System.in);

while(true) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bro 😭, You can't add tasks once you are in marking mode ?


line = in.nextLine();
String[] split_line = line.split(" ");

if (line.equals("list")) {

for (int i = 0; i < storer.size(); i++) {
System.out.println((i + 1) + ". " + mark_tracker.get(i) + " " + storer.get(i));
}

} else if (split_line[0].equals("mark")) {

int task_num = Integer.parseInt(split_line[1]) - 1;
mark_tracker.set(task_num, "[X]");
System.out.println("Nice! I've marked this task as done:");
System.out.println("[X] " + storer.get(task_num));

} else if (split_line[0].equals("unmark")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should have made 'unmark' as another method. That way it is easier to debug/make changes.

int task_num = Integer.parseInt(split_line[1]) - 1;
mark_tracker.set(task_num, "[]");
System.out.println("Ok, I've marked this task as not done yet:");
System.out.println("[] " + storer.get(task_num));
}
}


}
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

// level0();
// echo();
addList();
mark();

}
}