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

[Kwong Chung Yue Jerry] Duke Increments #354

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
65f72a8
Add support for Gradle workflow
j-lum Aug 6, 2019
0112efe
Add sample checkstyle configuration
j-lum Aug 12, 2019
cfd6da7
Change file mode on `gradle` to be executable
j-lum Aug 18, 2019
6e6ace1
Merge pull request #12 from j-lum/gradle+x
j-lum Aug 18, 2019
7a4a326
level-1
Aug 20, 2019
a8142cf
level-2
Aug 20, 2019
0f80053
level-3
Aug 20, 2019
a2b0ce6
level - 4
Aug 21, 2019
e8bcbc1
level - 5
Aug 22, 2019
06e54ae
level - 6
Aug 22, 2019
e4518be
level-7
Aug 26, 2019
5a363f9
level-7.1
Aug 27, 2019
c12d10f
level-8
Aug 27, 2019
b4f0619
Merge branch 'branch-level-8' into branch-level-7
Aug 27, 2019
3ae8135
merge with master
Aug 27, 2019
b598dce
more OOP
Aug 28, 2019
69dcfeb
more OOP
Aug 28, 2019
92f2560
JUnit Testing
Aug 28, 2019
b2e96ca
JUnit testing fix 1
Aug 28, 2019
06656d4
no message
Aug 28, 2019
e129cef
no message
Aug 28, 2019
5858c5c
level-JavaDoc
Aug 28, 2019
4b25475
level-9
Aug 28, 2019
9d83ec7
Merge branch 'branch-level-9'
Aug 28, 2019
c347dcd
no message
Aug 28, 2019
1930023
level-9.1
Aug 28, 2019
e24527d
level-9.2
Aug 28, 2019
0e13863
level-9.3
Aug 28, 2019
981a5b1
Merge branch 'gradle'
Aug 30, 2019
df314ce
A-Gradle
Sep 4, 2019
092d51f
A-Gradle
Sep 4, 2019
4e1f3d4
A-gradle
Sep 5, 2019
483de67
Merge pull request #2 from jerryk1997/A-Gradle
jerryk1997 Sep 5, 2019
53a9de5
Level-10
Sep 10, 2019
3999aba
Level-10
Sep 10, 2019
0d7daba
no message
Sep 11, 2019
cd36226
no message
Sep 13, 2019
a0d7621
no message
Sep 17, 2019
5533e7b
Merge pull request #4 from jerryk1997/A-Assertions
jerryk1997 Sep 17, 2019
0f0a057
Changes to improve code quality (#5)
jerryk1997 Sep 17, 2019
c9e7b3e
Added way for user to specify priorities of tasks
Sep 17, 2019
e748cdb
Merge pull request #6 from jerryk1997/C-Priority
jerryk1997 Sep 17, 2019
8840412
no message
Sep 28, 2019
975801f
no message
Sep 28, 2019
7359f03
no message
Sep 28, 2019
c3e6085
no message
Sep 28, 2019
a376a11
no message
Sep 28, 2019
676b00d
no message
Sep 28, 2019
8b248a0
no message
Sep 28, 2019
8d9d8e8
no message
Sep 28, 2019
b0e6354
no message
Sep 28, 2019
cd1d5f6
Editing the README.md
Sep 28, 2019
2410c7a
Updating the User Guide
Sep 28, 2019
21b28fd
no message
Sep 28, 2019
8833dab
Cross platform compatibility added
Sep 28, 2019
8c76a95
Added and ran checkstyle
Sep 29, 2019
73fa35f
no message
Sep 29, 2019
d9f432d
Updated java docs
Sep 29, 2019
b6c9579
no message
Sep 29, 2019
c122a3c
Updated user guide
Sep 29, 2019
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
Binary file added lib/apiguardian-api-1.0.0-javadoc.jar
Binary file not shown.
Binary file added lib/apiguardian-api-1.0.0-sources.jar
Binary file not shown.
Binary file added lib/apiguardian-api-1.0.0.jar
Binary file not shown.
Binary file added lib/junit-jupiter-5.4.2-javadoc.jar
Binary file not shown.
Binary file added lib/junit-jupiter-5.4.2-sources.jar
Binary file not shown.
Binary file added lib/junit-jupiter-5.4.2.jar
Binary file not shown.
Binary file added lib/junit-jupiter-api-5.4.2-javadoc.jar
Binary file not shown.
Binary file added lib/junit-jupiter-api-5.4.2-sources.jar
Binary file not shown.
Binary file added lib/junit-jupiter-api-5.4.2.jar
Binary file not shown.
Binary file added lib/junit-jupiter-engine-5.4.2-javadoc.jar
Binary file not shown.
Binary file added lib/junit-jupiter-engine-5.4.2-sources.jar
Binary file not shown.
Binary file added lib/junit-jupiter-engine-5.4.2.jar
Binary file not shown.
Binary file added lib/junit-jupiter-params-5.4.2-javadoc.jar
Binary file not shown.
Binary file added lib/junit-jupiter-params-5.4.2-sources.jar
Binary file not shown.
Binary file added lib/junit-jupiter-params-5.4.2.jar
Binary file not shown.
Binary file added lib/junit-platform-commons-1.4.2-javadoc.jar
Binary file not shown.
Binary file added lib/junit-platform-commons-1.4.2-sources.jar
Binary file not shown.
Binary file added lib/junit-platform-commons-1.4.2.jar
Binary file not shown.
Binary file added lib/junit-platform-engine-1.4.2-javadoc.jar
Binary file not shown.
Binary file added lib/junit-platform-engine-1.4.2-sources.jar
Binary file not shown.
Binary file added lib/junit-platform-engine-1.4.2.jar
Binary file not shown.
Binary file added lib/opentest4j-1.1.1-javadoc.jar
Binary file not shown.
Binary file added lib/opentest4j-1.1.1-sources.jar
Binary file not shown.
Binary file added lib/opentest4j-1.1.1.jar
Binary file not shown.
Binary file added src/main/java/Deadline.class
Binary file not shown.
94 changes: 94 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import java.time.LocalDateTime;

/**
* Deadline is a subclass of Task.
* Deadline represents a task with a description and a
* corresponding deadline.
*/
public class Deadline extends Task {
private String deadlineString;
private LocalDateTime deadlineDate;

/**
* Constructs a Deadline object.
* @param description Description of the task.
* @param deadline deadline of the task.
*/
public Deadline(String description, String deadline) {
super(description);

this.deadlineString = makeDeadline(deadline);
this.deadlineDate = storeAsDateTime(deadlineString);
}

/**
* Constructs a Deadline object.
* This constructor is for when the Deadline is being loaded
* from memory and hence can be already completed and the
* status of completion needs to be a parameter as well.
* @param description Description of the task
* @param deadline Date of the deadline
* @param status Status of completion
*/
public Deadline(String description, String deadline, boolean status) {
super(description);
this.deadlineString = makeDeadline(deadline);
this.deadlineDate = storeAsDateTime(deadlineString);
this.isDone = status;
}

/**
* Formats the String deadline.
* @param deadline Unformatted String deadline
* @return String Formatted String deadline
*/
public String makeDeadline(String deadline) {
StringBuilder temp = new StringBuilder();
String[] deadlineArr = deadline.split(" ");

temp.append(deadlineArr[0]);
if (!deadlineArr[0].contains(":")) {
temp.append(":");
}

for (int i = 1; i < deadlineArr.length; i++) {
temp.append(" ");
temp.append(deadlineArr[i]);
}

return temp.toString();
}

/**
* Converting to a format to be stored on file.
* Task is converted to a string that is stored on the
* hard disk, and can be read easily when loaded so that
* the information can be loaded onto the Task List when the
* program first starts.
* @return String Formatted string to be stored.
*/
@Override
public String toFileFormat() {
StringBuilder fileFormat = new StringBuilder();

fileFormat.append("D~");

if (this.isDone) {
fileFormat.append("1~");
} else {
fileFormat.append("0~");
}

fileFormat.append(this.description);
fileFormat.append("~");
fileFormat.append(this.deadlineString);

return fileFormat.toString();
}

@Override
public String toString() {
String task = "[D][" + this.getStatusIcon() + "] " + description + " (" + deadlineString + ")";
return task;
}
}
Binary file added src/main/java/Duke.class
Binary file not shown.
64 changes: 57 additions & 7 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,60 @@
import java.util.Scanner;
import java.io.IOException;

/**
* Duke is the main body of the program. It takes in the
* user's input and processes it accordingly.
*/
public class Duke {

private Storage storage;
private TaskList tasks;
private Ui ui;

public Duke(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
tasks = new TaskList(storage.load());
} catch (DukeException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

public void run() {
Scanner sc = new Scanner(System.in);
Parser parser = new Parser(ui);

ui.showWelcome();
String input = sc.nextLine();

while (true) {
try {

parser.parseCommand(input, tasks);
storage.update(tasks);

if (parser.isExit()) {
break;
}
input = sc.nextLine();

} catch (DukeException e) {

ui.showException(e);
input = sc.nextLine();

} catch (IOException e) {
System.out.println(e.getMessage());
}
}

ui.showGoodbye();
}


public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
new Duke("tasks.txt").run();
}
}
}
Binary file added src/main/java/DukeException.class
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class DukeException extends RuntimeException {
public DukeException(String message) {
super(message);
}
}
Binary file added src/main/java/Event.class
Binary file not shown.
94 changes: 94 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import java.time.LocalDateTime;

/**
* Event is a subclass of Task.
* Event describes something that is happening
* at a certain time.
*/
public class Event extends Task {
private String eventDateString;
private LocalDateTime eventDate;

/**
* Constructs a Event object.
* @param description Description of the event.
* @param deadline Date of the event.
*/
public Event(String description, String eventDate) {
super(description);
this.eventDateString = makeEventDate(eventDate);
this.eventDate = storeAsDateTime(eventDateString);
}

/**
* Constructs a Event object.
* This constructor is for when the Event is being loaded
* from memory and hence can be already completed and the
* status of completion needs to be a parameter as well.
* @param description Description of the task
* @param deadline Date of the deadline
* @param status Status of completion
*/
public Event(String description, String eventDate, boolean status) {
super(description);
this.eventDateString = makeEventDate(eventDate);
this.eventDate = storeAsDateTime(eventDateString);
Copy link

Choose a reason for hiding this comment

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

Can be replaced with this(description, eventDate);

this.isDone = status;
}

/**
* Formats the String date.
* @param eventDate Unformatted String date
* @return String Formatted String date
*/
public String makeEventDate(String eventDate) {
StringBuilder temp = new StringBuilder();
String[] eventDateArr = eventDate.split(" ");

temp.append(eventDateArr[0]);

if (!eventDateArr[0].contains(":")) {
temp.append(":");
}

for (int i = 1; i < eventDateArr.length; i++) {
temp.append(" ");
temp.append(eventDateArr[i]);
}

return temp.toString();
}

/**
* Converting to a format to be stored on file.
* Task is converted to a string that is stored on the
* hard disk, and can be read easily when loaded so that
* the information can be loaded onto the Task List when the
* program first starts.
* @return String Formatted string to be stored.
*/
@Override
public String toFileFormat() {
StringBuilder fileFormat = new StringBuilder();

fileFormat.append("E~");

if (this.isDone) {
fileFormat.append("1~");
} else {
fileFormat.append("0~");
}

fileFormat.append(this.description);
fileFormat.append("~");
fileFormat.append(this.eventDateString);

return fileFormat.toString();
}

@Override
public String toString() {
String task = "[E][" + this.getStatusIcon() + "] " + this.description + " (" + eventDateString + ")";
return task;
}
}
Binary file added src/main/java/IncorrectInputException.class
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/IncorrectInputException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class IncorrectInputException extends DukeException {
public IncorrectInputException(String message) {
super(message);
}
}
Binary file added src/main/java/NoDescriptionException.class
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/NoDescriptionException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class NoDescriptionException extends DukeException {
public NoDescriptionException(String message) {
super(message);
}
}
Binary file added src/main/java/NoExistingListException.class
Binary file not shown.
5 changes: 5 additions & 0 deletions src/main/java/NoExistingListException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class NoExistingListException extends DukeException {
public NoExistingListException(String message) {
super(message);
}
}
Binary file added src/main/java/Parser.class
Binary file not shown.
Loading