-
Notifications
You must be signed in to change notification settings - Fork 315
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
jerryk1997
wants to merge
60
commits into
nus-cs2103-AY1920S1:master
Choose a base branch
from
jerryk1997: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
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 0112efe
Add sample checkstyle configuration
j-lum cfd6da7
Change file mode on `gradle` to be executable
j-lum 6e6ace1
Merge pull request #12 from j-lum/gradle+x
j-lum 7a4a326
level-1
a8142cf
level-2
0f80053
level-3
a2b0ce6
level - 4
e8bcbc1
level - 5
06e54ae
level - 6
e4518be
level-7
5a363f9
level-7.1
c12d10f
level-8
b4f0619
Merge branch 'branch-level-8' into branch-level-7
3ae8135
merge with master
b598dce
more OOP
69dcfeb
more OOP
92f2560
JUnit Testing
b2e96ca
JUnit testing fix 1
06656d4
no message
e129cef
no message
5858c5c
level-JavaDoc
4b25475
level-9
9d83ec7
Merge branch 'branch-level-9'
c347dcd
no message
1930023
level-9.1
e24527d
level-9.2
0e13863
level-9.3
981a5b1
Merge branch 'gradle'
df314ce
A-Gradle
092d51f
A-Gradle
4e1f3d4
A-gradle
483de67
Merge pull request #2 from jerryk1997/A-Gradle
jerryk1997 53a9de5
Level-10
3999aba
Level-10
0d7daba
no message
cd36226
no message
a0d7621
no message
5533e7b
Merge pull request #4 from jerryk1997/A-Assertions
jerryk1997 0f0a057
Changes to improve code quality (#5)
jerryk1997 c9e7b3e
Added way for user to specify priorities of tasks
e748cdb
Merge pull request #6 from jerryk1997/C-Priority
jerryk1997 8840412
no message
975801f
no message
7359f03
no message
c3e6085
no message
a376a11
no message
676b00d
no message
8b248a0
no message
8d9d8e8
no message
b0e6354
no message
cd1d5f6
Editing the README.md
2410c7a
Updating the User Guide
21b28fd
no message
8833dab
Cross platform compatibility added
8c76a95
Added and ran checkstyle
73fa35f
no message
d9f432d
Updated java docs
b6c9579
no message
c122a3c
Updated user guide
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -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 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,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 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class DukeException extends RuntimeException { | ||
public DukeException(String message) { | ||
super(message); | ||
} | ||
} |
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 |
---|---|---|
@@ -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); | ||
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 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class IncorrectInputException extends DukeException { | ||
public IncorrectInputException(String message) { | ||
super(message); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class NoDescriptionException extends DukeException { | ||
public NoDescriptionException(String message) { | ||
super(message); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class NoExistingListException extends DukeException { | ||
public NoExistingListException(String message) { | ||
super(message); | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.
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.
Can be replaced with
this(description, eventDate);