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

[Eugene Ong Wei Xiang] iP #29

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
f6fd68b
Level-1 Done
Eugene-Ong-W-X Aug 14, 2022
7378eb9
Level-2 Done
Eugene-Ong-W-X Aug 16, 2022
a044c10
Level-3 Done
Eugene-Ong-W-X Aug 16, 2022
5fe495d
Level-4 Done
Eugene-Ong-W-X Aug 16, 2022
91f2fff
A-TextUiTesting Done
Eugene-Ong-W-X Aug 17, 2022
9658653
Level-5 Done
Eugene-Ong-W-X Aug 17, 2022
6f8dc32
Level-6 Done
Eugene-Ong-W-X Aug 17, 2022
30f5bb8
A-Enums Done
Eugene-Ong-W-X Aug 17, 2022
6d379a7
CheckStyle Done
Eugene-Ong-W-X Aug 17, 2022
2013e87
Add Level-7 | Read from & Write to File
Eugene-Ong-W-X Aug 20, 2022
84d0c49
Add Level-8 | Timestamps properly implemented
Eugene-Ong-W-X Aug 20, 2022
75f3d53
Merge branch 'branch-Level-7'
Eugene-Ong-W-X Aug 20, 2022
8209332
Merge branch 'branch-Level-8' into HEAD
Eugene-Ong-W-X Aug 20, 2022
b8119d6
More OOP | Add Ui, Parser, TaskList classes
Eugene-Ong-W-X Aug 20, 2022
7823c9c
Rename Duke/Alfred to Ren and Add 2 packages
Eugene-Ong-W-X Aug 20, 2022
422ded7
Merge branch 'add-gradle-support' of https://github.com/nus-cs2103-AY…
Eugene-Ong-W-X Aug 20, 2022
1f4739e
Add Gradle Support
Eugene-Ong-W-X Aug 20, 2022
f6491cf
Add JUnit Tests
Eugene-Ong-W-X Aug 20, 2022
6605c20
Release v0.2 (Packaging as JAR file)
Eugene-Ong-W-X Aug 20, 2022
2e039ea
Add JavaDoc
Eugene-Ong-W-X Aug 20, 2022
176828a
Java Standards: Fixed test codes
Eugene-Ong-W-X Aug 20, 2022
c7fc8d2
Add Find Feature
Eugene-Ong-W-X Aug 20, 2022
aa2133f
Merge branch 'branch-A-JavaDoc'
Eugene-Ong-W-X Aug 20, 2022
dc89a4b
Merge branch 'branch-A-CodingStandard'
Eugene-Ong-W-X Aug 20, 2022
1f496d9
Merge branch 'branch-Level-9'
Eugene-Ong-W-X Aug 20, 2022
443b11a
Use CheckStyle
Eugene-Ong-W-X Aug 25, 2022
7f9d8b9
Merge branch 'branch-A-CheckStyle'
Eugene-Ong-W-X Aug 25, 2022
3b647fc
Upgrade to GUI from Text UI
Eugene-Ong-W-X Aug 31, 2022
8562c90
Merge branch 'branch-Level-10'
Eugene-Ong-W-X Aug 31, 2022
730da76
Add and enable Assertions
Eugene-Ong-W-X Sep 3, 2022
5b3b597
Improve Code Quality
Eugene-Ong-W-X Sep 3, 2022
c925dde
Merge pull request #2 from Eugene-Ong-W-X/branch-A-CodeQuality
Eugene-Ong-W-X Sep 3, 2022
9122d13
Merge branch 'master' into branch-A-Assertions
Eugene-Ong-W-X Sep 3, 2022
64423eb
Merge pull request #1 from Eugene-Ong-W-X/branch-A-Assertions
Eugene-Ong-W-X Sep 3, 2022
1ee5cba
Set up Java CI using Github Actions
Eugene-Ong-W-X Sep 4, 2022
f2757f6
Fix for Java CI implementation
Eugene-Ong-W-X Sep 4, 2022
232a235
Fix 2 for Java CI implementation
Eugene-Ong-W-X Sep 4, 2022
1ec902d
Add Sort Feature
Eugene-Ong-W-X Sep 4, 2022
141d85e
Merge branch 'branch-BCD-Extension'
Eugene-Ong-W-X Sep 4, 2022
ebd82ba
Set up Ren Website
Eugene-Ong-W-X Sep 9, 2022
2683455
Update README.md
Eugene-Ong-W-X Sep 9, 2022
faad80a
Fix Code Quality
Eugene-Ong-W-X Sep 10, 2022
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
8 changes: 7 additions & 1 deletion src/main/java/ren/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
public class Parser {
/**
* Interprets user commands ad executes them.
* Interprets user commands and executes them.
*
* @param cmd Command to execute.
* @param tasks TaskList to execute commands on.
Expand Down Expand Up @@ -55,8 +55,10 @@ public static String parseCommand(String cmd, TaskList tasks) throws RenExceptio
: "0";
return tasks.deleteTask(Integer.parseInt(secondTerm));
} catch (NumberFormatException e) {
// If the second term parsed isn't an integer
throw new RenException("Please indicate the task no. in digits.");
} catch (RenException f) {
// The user entered an invalid number
return f.toString();
}
case "mark":
Expand All @@ -66,8 +68,10 @@ public static String parseCommand(String cmd, TaskList tasks) throws RenExceptio
: "0";
return tasks.updateTask(true, Integer.parseInt(secondTerm));
} catch (NumberFormatException e) {
// If the second term parsed isn't an integer
throw new RenException("Please indicate the task no. in digits.");
} catch (RenException f) {
// The user entered an invalid number
return f.toString();
}
case "unmark":
Expand All @@ -77,8 +81,10 @@ public static String parseCommand(String cmd, TaskList tasks) throws RenExceptio
: "0";
return tasks.updateTask(false, Integer.parseInt(secondTerm));
} catch (NumberFormatException e) {
// If the second term parsed isn't an integer
throw new RenException("Please indicate the task no. in digits.");
} catch (RenException f) {
// The user entered an invalid number
return f.toString();
}
case "list":
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/ren/Ren.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* Ren is a Task Manager program that helps a user keep track of and manage their tasks.
*/
public class Ren {
/** Stores the list of tasks added by the user. */
/** Stores and manages the list of tasks added by the user. */
private final TaskList tasks;

/** Manages the interaction between user and Ren. */
private final Ui ui = new Ui();

/**
Expand Down Expand Up @@ -40,6 +41,9 @@ public static void main(String[] args) {
new Ren().run();
}

/**
* The types of Tasks supported by Ren.
*/
enum TaskType {
TODO,
DEADLINE,
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/ren/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ public Storage(String filePath) {
init();
}

/**
* Initialises dataArray using dataFile and creates dataFile if it is missing.
*/
private void init() {
if (!dataFile.exists()) {
try {
// Check if the parent directory exists
if (!dataFile.getParentFile().exists()) {
dataFile.getParentFile().mkdir();
}
Expand All @@ -66,6 +70,9 @@ private void init() {
}
}

/**
* Resets the File to a blank File.
*/
private void newFile() {
try {
dataFile.delete();
Expand All @@ -75,6 +82,9 @@ private void newFile() {
}
}

/**
* Overwrite the File with a new list of Tasks.
*/
private void writeToFile() {
// Disable writing to File if error occurred during creation of file or reading of file.
if (hasError) {
Expand All @@ -94,6 +104,9 @@ private void writeToFile() {
}
}

/**
* Append a new Task's information to the File.
*/
private void appendToFile() {
// Disable writing to File if error occurred during creation of file or reading of file.
if (hasError) {
Expand Down Expand Up @@ -123,6 +136,7 @@ private void appendToFile() {
public ArrayList<Task> load() {
ArrayList<Task> tasks = new ArrayList<>();
for (int i = 0; i < this.counter; i++) {
// Split the task information into individual terms
String[] data = dataArray.get(i).split("\\|");
Task newTask = null;
switch (data[0]) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ren/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import ren.task.Task;
import ren.task.Todo;


/**
* TaskList contains a list of Tasks as well methods to add, delete, update tasks.
*/
public class TaskList {
/** ArrayList to store all Tasks. */
private final ArrayList<Task> tasks;

/** Storage to read and write all Tasks to File. */
/** Storage to synchronize all changes with. */
private final Storage storage;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ren/TimeStamp.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private TimeStamp(LocalDateTime timestamp) {
* @throws RenException If dateTime is not formatted correctly.
*/
public static TimeStamp of(String dateTime) throws RenException {
Copy link

Choose a reason for hiding this comment

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

This is completely up to you but I felt the method name for this factory method is a little short? Perhaps something like
public static TimeStamp **generateTimestamp**(String dateTime) throws RenException could be something a bit more descriptive? I do understand that "of" is used for the grammar to flow in another context, so feel free to ignore this!

// format of the date and time information in the input
DateTimeFormatter format = DateTimeFormatter.ofPattern("d/M/yyyy-H:mm");
try {
return new TimeStamp(LocalDateTime.parse(dateTime.strip(), format));
Expand All @@ -37,6 +38,7 @@ public static TimeStamp of(String dateTime) throws RenException {
* @return TimeStamp.
*/
public static TimeStamp fromFile(String dateTime) {
// format of the date and time information in the input
DateTimeFormatter format = DateTimeFormatter.ofPattern("E, d MMMM yyyy h:mm a");
try {
return new TimeStamp(LocalDateTime.parse(dateTime.strip(), format));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/ren/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public void greet() {
}

/**
* Say Goodbye to the user.
* Returns a Farewell message for the user.
*
* @return String with the Farewell message.
*/
public static String goodbye() {
return " Farewell!\n";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ren/task/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private Deadline(String description, TimeStamp dateTime) {
* @return Deadline Task or null if data is corrupted.
*/
public static Deadline readData(String[] data) {
// Check if data is complete
if (data.length < 4) {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ren/task/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private Event(String description, TimeStamp start, TimeStamp end) {
* @return Event or null if data is corrupted.
*/
public static Event readData(String[] data) {
// Check if data is complete
if (data.length < 5) {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ren/task/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public Todo(String description) {
* @return Todo Task or null if data is corrupted.
*/
public static Todo readData(String[] data) {
// Check if data is complete
if (data.length < 3) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/ren/RenExceptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public class RenExceptionTest {
@Test
public void toString_message_success() {
String message = "Test";
assertEquals(" Apologies! Test\n", new RenException(message).toString());
assertEquals(" >_< Apologies! Test\n", new RenException(message).toString());
}

@Test
public void toString_empty_success() {
assertEquals(" Apologies! \n", new RenException("").toString());
assertEquals(" >_< Apologies! \n", new RenException("").toString());
}
}