-
Notifications
You must be signed in to change notification settings - Fork 78
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
[kevinz420] iP #62
Open
kevinz420
wants to merge
16
commits into
nus-cs2113-AY2324S1:master
Choose a base branch
from
kevinz420:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[kevinz420] iP #62
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dc728ac
Added greeting skeleton
kevinz420 c78f17c
Added command echoing
kevinz420 a0623db
Added task tracking functionality
kevinz420 da4a93a
Added support for marking/unmarking tasks
kevinz420 a1fa50e
Added todos, events, and deadlines
kevinz420 dd65e0a
Added error handling
kevinz420 5c53fad
Merge branch 'branch-Level-5'
kevinz420 572ea6b
Refactored classes into packages
kevinz420 616f3ec
Added delete task functionality
kevinz420 102ab56
Refactor to use more OOP
kevinz420 8019e0a
Add find functionality
kevinz420 4f13039
Add JavaDoc comments
kevinz420 953157e
Merge pull request #1 from kevinz420/branch-Level-9
kevinz420 9f1c37f
Merge pull request #2 from kevinz420/branch-A-JavaDoc
kevinz420 b2585d9
Update README
kevinz420 86eb664
Added bug fixes for empty params
kevinz420 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,60 @@ | ||
import java.util.Scanner; | ||
|
||
public class Duke { | ||
private static Task[] tasks = new Task[100]; | ||
|
||
public static void main(String[] args) { | ||
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
System.out.println("Hello! I'm KevBot"); | ||
System.out.println("What can I do for you?"); | ||
|
||
|
||
Scanner in = new Scanner(System.in); | ||
String line; | ||
while (in.hasNextLine()) { | ||
line = in.nextLine(); | ||
if (line.equals("bye")) { | ||
break; | ||
} else if (line.equals("list")) { | ||
printTasks(); | ||
} else if (line.contains("mark")) { | ||
int divider = line.indexOf(" "); | ||
int idx = Integer.parseInt(line.substring(divider + 1)) - 1; | ||
if (idx < 0 || tasks[idx] == null) { | ||
System.out.println("Sorry! That's not a valid task"); | ||
kevinz420 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
continue; | ||
} | ||
|
||
markTask(idx, line.startsWith("mark")); | ||
kevinz420 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
addTask(line); | ||
} | ||
} | ||
System.out.println("Bye. Hope to see you again soon!"); | ||
} | ||
|
||
public static void markTask(int index, boolean isDone) { | ||
tasks[index].setStatus(isDone); | ||
if (isDone) { | ||
System.out.println("Nice! I've marked this task as done:"); | ||
} else { | ||
System.out.println("OK, I've marked this task as not done yet:"); | ||
} | ||
System.out.println(tasks[index].getFormattedTask()); | ||
} | ||
|
||
public static void printTasks() { | ||
for (int i = 0; i < tasks.length && tasks[i] != null; i++) { | ||
System.out.println((i + 1) + ". " + tasks[i].getFormattedTask()); | ||
} | ||
} | ||
|
||
public static void addTask(String task) { | ||
for (int i = 0; i < tasks.length; i ++) { | ||
if (tasks[i] == null) { | ||
tasks[i] = new Task(task); | ||
break; | ||
} | ||
} | ||
System.out.println("added: " + task); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe can check "bye" condition here