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

[waiter-palypoo] ip #193

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7faa1cb
Add HinaBot.java
waiter-palypoo Jan 26, 2023
0e9f153
Refactor greeting message and add handleCommand method to echo user i…
waiter-palypoo Jan 27, 2023
565a8e1
Add code for adding items to a list and printing the list
waiter-palypoo Jan 31, 2023
3d00890
Add Task class, add code to mark and unmark tasks
waiter-palypoo Feb 1, 2023
7e758c3
Add support for todo, deadline and event task types.
waiter-palypoo Feb 1, 2023
e13adce
no message
waiter-palypoo Feb 1, 2023
752a280
Merge commit '7e758c3a91d41d43006c379c502de1ceb83a4e1f' into HEAD
waiter-palypoo Feb 1, 2023
c47e253
Resolved error resulting from RCS mistake
waiter-palypoo Feb 1, 2023
e40dfd0
Add code to handle unknown command, insufficient detail exceptions.
waiter-palypoo Feb 14, 2023
203f936
Merge branch 'branch-Level-5'
waiter-palypoo Feb 14, 2023
367c9fd
Divide classes into packages
waiter-palypoo Feb 14, 2023
65eef30
Add method to delete tasks, fixed coding standard violations, change …
waiter-palypoo Feb 28, 2023
c890a60
Add functionality to save task list to a .txt file.
waiter-palypoo Feb 28, 2023
07e9a22
Merge branch 'branch-Level-6'
waiter-palypoo Feb 28, 2023
1071390
Merge branch 'branch-Level-7'
waiter-palypoo Feb 28, 2023
3b7e16a
Refactor functionality into Parser, Ui, Storage and TaskList classes.
waiter-palypoo Mar 1, 2023
b0dc677
Add date-time format support
waiter-palypoo Mar 2, 2023
2f02a85
Add method to search for items by matching substrings in Task descrip…
waiter-palypoo Mar 2, 2023
0e9aa9a
Merge pull request #1 from waiter-palypoo/branch-Level-8
waiter-palypoo Mar 2, 2023
4af6cef
Merge branch 'master' of https://github.com/waiter-palypoo/ip
waiter-palypoo Mar 2, 2023
da2844c
Merge branch 'master' into branch-Level-9
waiter-palypoo Mar 2, 2023
4c64d87
Merge pull request #2 from waiter-palypoo/branch-Level-9
waiter-palypoo Mar 2, 2023
bf6fe2d
Merge branch 'master' of https://github.com/waiter-palypoo/ip into br…
waiter-palypoo Mar 2, 2023
4e01561
Merge branch 'branch-Level-9'
waiter-palypoo Mar 2, 2023
ecce69f
Optimise imports for Deadline and Event classes
waiter-palypoo Mar 2, 2023
019af43
Add JavaDoc comments for multiple classes and methods. Refactor some …
waiter-palypoo Mar 3, 2023
c915504
Merge pull request #3 from waiter-palypoo/branch-A-JavaDoc
waiter-palypoo Mar 3, 2023
b195b1d
Merge branch 'master' of https://github.com/waiter-palypoo/ip
waiter-palypoo Mar 3, 2023
5a621ec
Updated user guide, changed find method to print the index of matchin…
waiter-palypoo Mar 3, 2023
29dcae7
Fix bugs involving invalid inputs for mark, unmark and delete methods
waiter-palypoo Mar 17, 2023
d207461
Build jar file
waiter-palypoo Mar 17, 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
74 changes: 74 additions & 0 deletions src/main/java/HinaBot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import java.util.Scanner;

public class HinaBot {
protected static Task[] taskList = new Task[100];
protected static int taskCount = 0;
public static void main(String[] args) {
String line;
Scanner in = new Scanner(System.in);
showGreeting();
while (true) {
line = in.nextLine();
handleCommand(line);
}
}

private static void showGreeting() {
System.out.println("Hello master!");
System.out.println("What are your orders?");
}

public static void handleCommand(String command) {
if (command.equalsIgnoreCase("bye")) {
System.out.println("Goodbye master, let's meet again soon...");
System.exit(0);
}
else if (command.equalsIgnoreCase("list")) {
listTasks();
}
else if (command.split(" ")[0].equalsIgnoreCase("mark")) {
int taskIndex = Integer.parseInt(command.split(" ")[1]);
markTask(taskIndex);
}
else if (command.split(" ")[0].equalsIgnoreCase("unmark")) {
int taskIndex = Integer.parseInt(command.split(" ")[1]);
unmarkTask(taskIndex);
}
else {
addTask(command);
}
}

public static void addTask(String description) {
Task newTask = new Task(description);
taskList[taskCount] = newTask;
taskCount++;
System.out.println("added: " + description);
}

public static void listTasks() {
for (int i = 0; i < taskCount; i++) {
System.out.print(i + 1);
System.out.print(". ");
if (taskList[i].isDone()) {
System.out.print("[X] ");
}
else {
System.out.print("[ ] ");
}
System.out.println(taskList[i].getDescription());
}
}

public static void markTask(int taskIndex) {
taskList[taskIndex - 1].setDone(true);
System.out.println("Roger that! This task is marked as done: ");
System.out.println("[X] " + taskList[taskIndex - 1].getDescription());
}

public static void unmarkTask(int taskIndex) {
taskList[taskIndex - 1].setDone(false);
System.out.println("Roger that! This task is marked as done: ");
System.out.println("[ ] " + taskList[taskIndex - 1].getDescription());
}
Copy link

Choose a reason for hiding this comment

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

No coding violations at all!

}
Copy link

Choose a reason for hiding this comment

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

Nice!

Copy link

Choose a reason for hiding this comment

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

Nice! No Coding Violations

Copy link

Choose a reason for hiding this comment

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

Good job!

24 changes: 24 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
public class Task {
private String description;
private boolean isDone;
public boolean isDone() {
return isDone;
}

public void setDone(boolean done) {
isDone = done;
}

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

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
}
Copy link

Choose a reason for hiding this comment

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

Good job!