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

[Andrea Tan] iP #263

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
af7e8f9
Level 1 complete
andrea-twl Jan 31, 2021
c621220
Level-2 complete
andrea-twl Jan 31, 2021
b3a5323
Level-3 complete
andrea-twl Jan 31, 2021
25b1d6b
level-4 completed (implemented ToDo.java, Deadline.java and Event.jav…
andrea-twl Feb 1, 2021
dd45d1b
Level-5 complete (added DukeIncompleteCommandException.java and DukeI…
andrea-twl Feb 3, 2021
26418a3
Level-6 completed (added delete function)
andrea-twl Feb 3, 2021
0a0fc47
Level-7 complete (save and load - added saveFile() and loadFIle(), as…
andrea-twl Feb 8, 2021
18b425d
Level-8 complete (added date, recoded loadFile(), handled exceptions)
andrea-twl Feb 8, 2021
a7089c6
Merge branch 'branch-Level-8'
andrea-twl Feb 8, 2021
75632ce
Merge branch 'branch-Level-7'
andrea-twl Feb 8, 2021
2061878
A-MoreOOP (added Tasklist.java, Storage.java, Parser.java and UI.java)
andrea-twl Feb 14, 2021
b785eec
A-JUnit (added ParserTest.java, TodoTest.java and DukeTest.java)
andrea-twl Feb 16, 2021
5ea5f47
A-JavaDoc (added JavaDocs to most classes)
andrea-twl Feb 19, 2021
1f42308
A-CodingStandard (fixed tabs, added line breaks)
andrea-twl Feb 20, 2021
8b0510b
Level-9 complete (Find)
andrea-twl Feb 20, 2021
e7cb203
Merge branch 'branch-A-CodingStandard'
andrea-twl Feb 20, 2021
3038258
Merge branch 'branch-Level-9'
andrea-twl Feb 20, 2021
c475678
Level-10 GUI
andrea-twl Feb 22, 2021
b5e8f0f
Bug fixes - reconfigured duke package
andrea-twl Feb 23, 2021
a61b6df
A-Assertions
andrea-twl Feb 23, 2021
62293f2
A-CodeQuality
andrea-twl Feb 23, 2021
081fe4e
Merge pull request #2 from andrea-twl/branch-A-Assertions
andrea-twl Feb 23, 2021
c9172b6
merge commit
andrea-twl Feb 23, 2021
1abb403
Merge branch 'master' into branch-A-CodeQuality
andrea-twl Feb 23, 2021
ae13b46
BCD-Extension (added C-Sort)
andrea-twl Feb 23, 2021
382cb20
Merge branch 'branch-A-CodeQuality'
andrea-twl Feb 23, 2021
e6d3f36
Updated README, added help menu
andrea-twl Feb 24, 2021
be967e3
Set theme jekyll-theme-cayman
andrea-twl Feb 24, 2021
ddd5d12
Update README.md
andrea-twl Feb 24, 2021
b7d0bbe
added Ui.png
andrea-twl Feb 24, 2021
7e15137
Merge branch 'master' of https://github.com/andrea-twl/ip
andrea-twl Feb 26, 2021
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
67 changes: 39 additions & 28 deletions src/com/jetbrains/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Scanner;
import java.util.ArrayList;
import java.lang.Throwable;

public class Duke {

Choose a reason for hiding this comment

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

Maybe some java docs will be useful to make the user understand the code better!

public static void main(String[] args) {
Expand All @@ -21,38 +20,50 @@ public static void main(String[] args) {
while (!input.equals("bye")) {
Task task;
try {
if (input.equals("list")) {
displayList(list);
System.out.println("\n");
} else if (input.contains("done")) {
String[] doneCommand = input.split(" ");
task = list.get(Integer.parseInt(doneCommand[1]) - 1);
System.out.println("Good job! I've marked this task as done:\n " +
task.markDone() +
"\n");
} else if (input.contains("todo") ||
input.contains("deadline") ||
input.contains("event")) {
if (input.equals("list")) {
displayList(list);
System.out.println("\n");
} else if (input.contains("done")) {
String[] command = input.split(" ");
task = list.get(Integer.parseInt(command[1]) - 1);
System.out.println("Good job! I've marked this task as done:\n " +

Choose a reason for hiding this comment

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

I think it's good that you kept the line of print statement short:>

task.markDone() +
"\n");
} else if (input.contains("delete")) {

Choose a reason for hiding this comment

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

do you think maybe switch statements could be used to make the code look more concise?

String[] command = input.split(" ");
int index = Integer.parseInt(command[1]) - 1;
task = list.get(index);
System.out.println("Alright, I've deleted this task:\n " +
task +
"\n");
list.remove(index);
System.out.println("Now you have " + list.size() +
" task(s) in the list. \n");
} else if (input.contains("todo") ||
input.contains("deadline") ||
input.contains("event")) {

if (input.contains("todo")) {
task = new ToDo(input);
} else if (input.contains("deadline")) {
task = new Deadline(input);
} else {
task = new Event(input);
}
list.add(task);
System.out.println("I'll take note! \n added: " +
task + "\nNow you have " + list.size() +
" task(s) in the list. \n");
if (input.contains("todo")) {
task = new ToDo(input);
} else if (input.contains("deadline")) {
task = new Deadline(input);
} else {
task = new Event(input);
}
list.add(task);
System.out.println("Alright! I've added this task: \n " +
task + "\nNow you have " + list.size() +
" task(s) in the list. \n");
} else {

Choose a reason for hiding this comment

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

I think it is great that you implemented Duke Exceptions early!

throw new DukeInvalidCommandException();
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
input = sc.nextLine();
} catch (IndexOutOfBoundsException e) {
System.out.println("Oh no! This task does not exist. D:" );
} catch (Exception e) {
System.out.println(e.getMessage());
}
input = sc.nextLine();
}

sc.close();
System.out.println("Bye! Stay on task!");
Expand Down