Skip to content
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

[Barbaracwx] iP #67

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
999081b
Change name of bot
Barbaracwx Aug 31, 2023
c129070
commit echo
Barbaracwx Sep 4, 2023
23d1e0e
commit level 2: add, list
Barbaracwx Sep 4, 2023
182f0f5
commit level 3: mark as done
Barbaracwx Sep 4, 2023
69a4ae4
commit coding standard
Barbaracwx Sep 4, 2023
8842184
commint Level 4. ToDos, Events, Deadlines
Barbaracwx Sep 6, 2023
f824dfe
commit: improve code quality
Barbaracwx Sep 8, 2023
70ba578
add increment as a branch, level 5
Barbaracwx Sep 15, 2023
0894d39
Merge branch 'branch-Level-5'
Barbaracwx Sep 15, 2023
a0f798a
Organize classes into the 'duke' package
Barbaracwx Sep 15, 2023
2987979
Merge branch 'branch-A-Packages'
Barbaracwx Sep 15, 2023
9beff6f
Implement Level-6
Barbaracwx Sep 20, 2023
786c27b
Implement Level-7
Barbaracwx Sep 22, 2023
327d3d4
Merge branch 'branch-Level-6'
Barbaracwx Sep 22, 2023
5fe3f31
Implement Level-7
Barbaracwx Sep 22, 2023
9e14e1d
Added A-jar level
Barbaracwx Sep 22, 2023
d2ed96a
commit updated changes
Barbaracwx Sep 28, 2023
6425ae4
Implement A-Exceptions Tag
Barbaracwx Sep 28, 2023
2423d8a
level 5
Barbaracwx Sep 28, 2023
ef461a8
implemented A-Collections Tag
Barbaracwx Sep 28, 2023
36a4072
Merge branch 'branch-Level-7'
Barbaracwx Sep 28, 2023
36a6f2b
commit added parser,command, tasklist and ui class
Barbaracwx Oct 2, 2023
98a143a
Implement find
Barbaracwx Oct 2, 2023
87b9da0
Merge pull request #1 from Barbaracwx/branch-Level-9
Barbaracwx Oct 2, 2023
4df8bd3
Added JavaDoc comments
Barbaracwx Oct 3, 2023
6d2c93b
Merge pull request #2 from Barbaracwx/branch-A-JavaDoc
Barbaracwx Oct 3, 2023
139e288
Organised code
Barbaracwx Oct 3, 2023
dd53bc2
change name of file
Barbaracwx Oct 3, 2023
b073a6f
organised files
Barbaracwx Oct 3, 2023
b913271
Update README.md
Barbaracwx Oct 3, 2023
a58e292
Update README.md
Barbaracwx Oct 3, 2023
c03627a
Update README.md
Barbaracwx Oct 3, 2023
8b10039
Update README.md
Barbaracwx Oct 3, 2023
fc929e4
Update README.md
Barbaracwx Oct 3, 2023
2976ed5
Update README.md
Barbaracwx Oct 3, 2023
2bc67ee
Update README.md
Barbaracwx Oct 3, 2023
3f173b3
Update README.md
Barbaracwx Oct 3, 2023
7437537
Update README.md
Barbaracwx Oct 3, 2023
64ef5a1
Update README.md
Barbaracwx Oct 3, 2023
a1a8f04
Update README.md
Barbaracwx Oct 3, 2023
3f61c50
Update README.md
Barbaracwx Oct 3, 2023
f7d6c25
Added user guide
Barbaracwx Oct 5, 2023
b2c8537
Merge branch 'master' of https://github.com/Barbaracwx/ip
Barbaracwx Oct 5, 2023
a480276
Edited code
Barbaracwx Oct 6, 2023
db152b1
Updated code
Barbaracwx Oct 6, 2023
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
2 changes: 2 additions & 0 deletions src/main/java/DeadlineTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class DeadlineTask {
}

Choose a reason for hiding this comment

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

You might want to add some spaces between the package and the class.

Suggested change
package PACKAGE_NAME;public class DeadlineTask {
}
package PACKAGE_NAME;
public class DeadlineTask {
}

65 changes: 58 additions & 7 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,61 @@
import java.util.Scanner;

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println("____________________________________________________________");
System.out.println("Hello! I'm Calebra\nWhat can I do for you?");
System.out.println("____________________________________________________________");

Scanner input = new Scanner(System.in);
Task[] tasks = new Task[100];
int taskCount = 0;

String line = input.nextLine();

Choose a reason for hiding this comment

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

Consider changing your variable name to something more appropriate such as userInput.

while (!line.equals("bye")) {

System.out.println("____________________________________________________________");
if (line.equals("list")) {
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < taskCount; i++) {
System.out.println((i + 1) + ". " + tasks[i]);
}
} else if (line.startsWith("mark")) {
int taskIndex = Integer.parseInt(line.substring(5)) - 1;
if (taskIndex >= 0 && taskIndex < taskCount) {
tasks[taskIndex].markAsDone();
System.out.println("Nice! I've marked this task as done:\n" + tasks[taskIndex].toString());
}
} else {
String[] parts = line.split(" ", 2);

Choose a reason for hiding this comment

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

Good use of plurality for naming "parts"

String command = parts[0];
String taskDescription = parts.length > 1 ? parts[1] : "";

switch (command) {

Choose a reason for hiding this comment

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

Right use of indentation for switch case

Choose a reason for hiding this comment

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

Perhaps you could consider creating a separate method for the switch case

case "todo":
tasks[taskCount] = new TodoTask(taskDescription);
break;
case "deadline":
tasks[taskCount] = new DeadlineTask(taskDescription);
break;
case "event":
tasks[taskCount] = new EventTask(taskDescription);
break;
default:

Choose a reason for hiding this comment

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

I like how you handle invalid inputs for the switch case.

System.out.println("Invalid command. Please use 'todo', 'deadline', 'event', or 'list'.");
}
taskCount++;
System.out.println("Got it. I've added this task: ");
System.out.println(tasks[taskCount - 1].toString());
System.out.println("Now you have " + taskCount + " tasks in the list.");
}

System.out.println("____________________________________________________________\n");
line = input.nextLine();
}

// When the user types "bye," exit the loop and display the goodbye message
System.out.println("____________________________________________________________");
System.out.println("Bye! Hope to see you again soon!");
System.out.println("____________________________________________________________");
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/EventTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class EventTask {
}
30 changes: 30 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Task {
private String description;
private boolean isDone;

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

public void markAsDone() {
isDone = true;
}

public void markAsNotDone() {
isDone = false;
}

public String getDescription() {
return description;
}

public String getStatusIcon() {

Choose a reason for hiding this comment

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

Good use of camelCase for method

return (isDone ? "X" : " ");
}

@Override

Choose a reason for hiding this comment

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

Good use of @OverRide to show overriding of parent's method

public String toString() {
return "[" + getStatusIcon() + "] " + description;
}
}
2 changes: 2 additions & 0 deletions src/main/java/TodoTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class TodoTask {
}