-
Notifications
You must be signed in to change notification settings - Fork 187
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
[hongyijie06] iP #179
Open
hongyijie06
wants to merge
33
commits into
nus-cs2113-AY2324S2:master
Choose a base branch
from
hongyijie06: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
[hongyijie06] iP #179
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f0ecd9c
add chatbot name
hongyijie06 e0b6eed
Add echo
hongyijie06 35ec609
add Add,list
hongyijie06 0c16724
add mark as done
hongyijie06 1b6ca15
add A-CodingStandard
hongyijie06 6ef3078
add todo, deadline and event
hongyijie06 b540106
add code quality
hongyijie06 c230255
add error handling
hongyijie06 bedc8ec
make error handling more error-specific
hongyijie06 4793c54
Revert "make error handling more error-specific"
hongyijie06 c43aef3
Revert "Revert "make error handling more error-specific""
hongyijie06 e0bf4a2
add delete
hongyijie06 7078d98
Merge branch 'branch-Level-6'
hongyijie06 4de283c
settle errors
hongyijie06 e44d14e
add save
hongyijie06 011c695
resolve errors
hongyijie06 0bc39f6
Merge branch 'branch-Level-7'
hongyijie06 b1fd82d
fix formatting when listing tasks
hongyijie06 61216db
add saveToFile
hongyijie06 996ba2b
fix file not found error
hongyijie06 7162ac7
use more oop
hongyijie06 7a5826c
fix loading file errors
hongyijie06 4a60dbe
add find
hongyijie06 422ac12
Merge branch 'branch-Level-9'
hongyijie06 2152ef7
add javadoc
hongyijie06 b611a02
Merge pull request #1 from hongyijie06/branch-A-JavaDoc
hongyijie06 d141099
Merge branch 'master' of https://github.com/hongyijie06/ip
hongyijie06 6752306
Add user guide
hongyijie06 2f4b481
Format headers
hongyijie06 4f03af2
follow coding standards
hongyijie06 fbcc37c
add README pictures
hongyijie06 456bcb0
add pictures
hongyijie06 dc9a769
improve formatting, no pictures
hongyijie06 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
Binary file not shown.
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,48 @@ | ||
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); | ||
Task[] list = new Task[100]; | ||
|
||
//greeting | ||
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. Your comment could be more descriptive! |
||
System.out.println("Hello! I'm Apple"); | ||
System.out.println("What can I do for you?"); | ||
|
||
int index = 0;//number of items in the list | ||
String line = " "; | ||
|
||
while (!line.equals("bye")) { | ||
Scanner input = new Scanner(System.in); | ||
line = input.nextLine(); | ||
|
||
Task t = new Task(line); | ||
String[] inputs = line.split(" "); | ||
|
||
if (inputs[0].equals("mark")) {//mark as done | ||
int idx = Integer.parseInt(inputs[1]); | ||
list[idx - 1].markAsDone(); | ||
System.out.println("Nice! I've marked this task as done: "); | ||
System.out.println("[" + list[idx - 1].getStatusIcon() + "]" + list[idx - 1].description); | ||
} else if (inputs[0].equals("unmark")) {//unmark done | ||
int idx = Integer.parseInt(inputs[1]); | ||
list[idx - 1].unmarkDone(); | ||
System.out.println("OK, I've marked this task as not done yet: "); | ||
System.out.println("[" + list[idx - 1].getStatusIcon() + "]" + list[idx - 1].description); | ||
} else if (line.equals("list")) {//lists items | ||
System.out.println("Here are the tasks in your list: "); | ||
for (int i = 0; i < index; i++) { | ||
System.out.println((i + 1) + ". [" + list[i].getStatusIcon() + "]" + list[i].description); | ||
} | ||
} else if (line.equals("bye")) {//exit chat | ||
break; | ||
} else {//add items | ||
list[index] = t; | ||
System.out.println("added: " + t.description); | ||
index++; | ||
} | ||
|
||
} | ||
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. you can try to use more methods e.g. sayBey() to make the program more extendable for the future levels. |
||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
public class Task { | ||
protected String description; | ||
protected boolean isDone; | ||
public Task(String description) { | ||
this.description = description; | ||
this.isDone = false; | ||
} | ||
|
||
public String getStatusIcon() { | ||
return (isDone ? "X" : " "); // mark done task with X | ||
} | ||
|
||
public void markAsDone() { | ||
this.isDone = true; | ||
} | ||
|
||
public void unmarkDone() { | ||
this.isDone = false; | ||
} | ||
} | ||
|
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.
You can try to use Arraylist which is more convenient in java