-
Notifications
You must be signed in to change notification settings - Fork 114
[Qin Kai] iP #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Qin Kai] iP #98
Changes from 3 commits
517cbb7
1a784d3
2585910
1e3dbd6
94390c0
77151b3
c6668cd
03e144a
8940ee6
3dcb73b
5046611
fe57d16
f74f207
72a5578
79ca35c
0098143
8216257
df24974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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 { | ||
|
|
||
| private static final ArrayList<String> storer = new ArrayList<>(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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<>(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line should not be here? The chatbot prints Bye almost instantly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bye should not be in level 0 |
||
| } | ||
|
|
||
| public static void echo() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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")) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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")) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
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.