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
Show file tree
Hide file tree
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
23 changes: 17 additions & 6 deletions src/com/jetbrains/Deadline.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
package com.jetbrains;

import java.lang.Throwable;
public class Deadline extends Task {
String dueDate;
Copy link

Choose a reason for hiding this comment

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

I think dueDate should be used instead of by as the former is more understandable!

String by;

Deadline(String input) {
String[] inputs = input.trim().split("/by ");
this.task = inputs[0].substring(9);
Deadline(String input) throws DukeIncompleteCommandException {
input = input.substring(8).trim();

if (input.equals("")) {
throw new DukeIncompleteCommandException();
}

String[] inputs = input.split("/by");

if (!input.contains("/by") || inputs.length < 2) {
throw new DukeIncompleteCommandException("Oh no! Please enter an due date. :P");
}
this.task = inputs[0];
this.isDone = false;
this.dueDate = inputs[1];
this.by = inputs[1].trim();
}

@Override
public String toString() {
return String.format("DDLN%s (by: %s)" ,
super.toString(), dueDate);
super.toString(), by);
}
}
23 changes: 17 additions & 6 deletions src/com/jetbrains/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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 @@ -18,17 +19,21 @@ public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
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 task = list.get(Integer.parseInt(doneCommand[1]) - 1);
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 {
Task task;
} else if (input.contains("todo") ||
input.contains("deadline") ||
input.contains("event")) {

if (input.contains("todo")) {
task = new ToDo(input);
} else if (input.contains("deadline")) {
Expand All @@ -39,10 +44,16 @@ public static void main(String[] args) {
list.add(task);
System.out.println("I'll take note! \n added: " +
task + "\nNow you have " + list.size() +
" task(s) in the list. \n" );
" 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();
}
input = sc.nextLine();
}

sc.close();
System.out.println("Bye! Stay on task!");
}
Expand Down
18 changes: 18 additions & 0 deletions src/com/jetbrains/DukeIncompleteCommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.jetbrains;

public class DukeIncompleteCommandException extends Exception {
public String message;
DukeIncompleteCommandException() {
this.message = "Oh no! Task cannot be empty. ):";
}
DukeIncompleteCommandException(String message) {
this.message = message;
}
@Override
public String getMessage() {
return message;
}
public String toString() {
return message;
}
}
16 changes: 16 additions & 0 deletions src/com/jetbrains/DukeInvalidCommandException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.jetbrains;

public class DukeInvalidCommandException extends Exception {
public String message = "Oh no! I don't know what that means. ):";
DukeInvalidCommandException() {
}

@Override
public String getMessage() {
return message;
}

public String toString() {
return message;
}
}
25 changes: 19 additions & 6 deletions src/com/jetbrains/Event.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package com.jetbrains;

import java.lang.Throwable;
public class Event extends Task {
String eventDate;
String at;

Event(String input) {
String[] inputs = input.trim().split("/at ");
this.task = inputs[0].substring(6);
Event(String input) throws DukeIncompleteCommandException {
input = input.substring(5).trim();

if (input.equals("")) {
throw new DukeIncompleteCommandException();
}

String[] inputs = input.split("/at");

if (!input.contains("/at") || inputs.length < 2) {
throw new DukeIncompleteCommandException("Oh no! Please enter an event date. :P");
}

this.task = inputs[0];
this.isDone = false;
this.eventDate = inputs[1];
this.at = inputs[1].trim();
}


@Override
public String toString() {
return String.format("EVNT%s (at: %s)" ,
super.toString(), eventDate);
super.toString(), at);
}
}
10 changes: 8 additions & 2 deletions src/com/jetbrains/ToDo.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.jetbrains;

import java.lang.Throwable;
public class ToDo extends Task {
ToDo(String input) {
this.task = input.trim().substring(5);
ToDo(String input) throws DukeIncompleteCommandException {
input = input.substring(4).trim();
if (input.equals("")) {
throw new DukeIncompleteCommandException();
}
this.task = input;
this.isDone = false;
}

@Override
public String toString() {
return "TODO" + super.toString();
Expand Down