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

[jellywaiyan] iP #538

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
28ad2b8
Add Gradle support
May 24, 2020
ed6d4d2
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
5f41e1b
Level-0
jellywaiyan Aug 22, 2023
7845ef4
Leve-1
jellywaiyan Aug 22, 2023
0a8f1fa
Level-2
jellywaiyan Aug 23, 2023
d757c5a
Level-3
jellywaiyan Aug 23, 2023
855fdbe
Level-4
jellywaiyan Aug 23, 2023
8ad03a0
A-TextUiTesting
jellywaiyan Aug 23, 2023
9e78b42
Level-5
jellywaiyan Aug 24, 2023
4a262ae
Level-6
jellywaiyan Aug 24, 2023
f98495d
Level-6
jellywaiyan Aug 24, 2023
a1abb5f
Level-7
jellywaiyan Sep 3, 2023
8708c8a
Level-7v2
jellywaiyan Sep 3, 2023
4dbc78f
Merge branch 'branch-Level-7'
jellywaiyan Sep 3, 2023
a6a9d84
Level-8 deadline done, event left to do
jellywaiyan Sep 3, 2023
7196ad9
Level-8
jellywaiyan Sep 3, 2023
8418609
Merge branch 'branch-Level-8'
jellywaiyan Sep 3, 2023
ffc0ca4
Add Storage, TaskList, Ui
jellywaiyan Sep 3, 2023
9196ca0
A-MoreOOP
jellywaiyan Sep 4, 2023
f4cfe37
Merge remote-tracking branch 'jellywaiyan/A-MoreOOP'
jellywaiyan Sep 4, 2023
40dccfa
A-Packages
jellywaiyan Sep 4, 2023
ec17221
Merge remote-tracking branch 'jellywaiyan/A-Packages'
jellywaiyan Sep 4, 2023
1036713
Merge remote-tracking branch 'jellywaiyan/master' into add-gradle-sup…
jellywaiyan Sep 4, 2023
eb3af70
A-Gradle
jellywaiyan Sep 4, 2023
e349452
A-JUnit
jellywaiyan Sep 6, 2023
298034b
Merge remote-tracking branch 'jellywaiyan/A-JUnit'
jellywaiyan Sep 6, 2023
7153636
A-Jar
jellywaiyan Sep 6, 2023
f296862
Merge tag 'A-Jar'
jellywaiyan Sep 6, 2023
f424f95
Added javadocs to most methods/classes
jellywaiyan Sep 6, 2023
092aca3
A-CodingStandard
jellywaiyan Sep 6, 2023
ef85ff8
Level-9
jellywaiyan Sep 6, 2023
accd66b
Merge remote-tracking branch 'jellywaiyan/A-JavaDoc'
jellywaiyan Sep 6, 2023
aa8546d
Merge remote-tracking branch 'jellywaiyan/A-CodingStandard'
jellywaiyan Sep 6, 2023
c4e9d23
Merge remote-tracking branch 'jellywaiyan/Level-9'
jellywaiyan Sep 6, 2023
69dfcb2
A-CheckStyle
jellywaiyan Sep 9, 2023
78be3ef
A-CheckStyle
jellywaiyan Sep 9, 2023
5797609
Merge remote-tracking branch 'jellywaiyan/A-CheckStyle'
jellywaiyan Sep 9, 2023
cb808e7
Level-10
jellywaiyan Sep 12, 2023
4e8dd06
Merge remote-tracking branch 'jellywaiyan/branch-Level-10'
jellywaiyan Sep 12, 2023
21c4475
Improve code quality by making methods more efficient and readable.
jellywaiyan Sep 22, 2023
43f2b52
Merge pull request #2 from jellywaiyan/branch-A-CodeQuality
jellywaiyan Sep 22, 2023
22a0934
Current implementation does not use assertions.
jellywaiyan Sep 23, 2023
7c36a44
Small change
jellywaiyan Sep 23, 2023
aef83c9
Merge branch 'master' into A-Assertions
jellywaiyan Sep 23, 2023
288f645
Merge A-Assertions
jellywaiyan Sep 23, 2023
fc579d9
Merge pull request #3 from jellywaiyan/A-Assertions
jellywaiyan Sep 23, 2023
ccfa675
Fix checkstyle
jellywaiyan Sep 23, 2023
86abced
Add priority to tasks
jellywaiyan Sep 23, 2023
5a0e075
Add priority
jellywaiyan Sep 23, 2023
74fff83
Merge remote-tracking branch 'jellywaiyan/C-Priority'
jellywaiyan Sep 23, 2023
1af5407
Change README, add Ui.png
jellywaiyan Sep 23, 2023
4015151
Configure jar file
jellywaiyan Sep 23, 2023
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
2 changes: 1 addition & 1 deletion src/main/java/Jelly/commands/ByeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void execute(TaskList taskList, Ui ui, Storage storage) {
ui.byeMessage();
}

public boolean running() {
public boolean isRunning() {
return false;
}
}
2 changes: 1 addition & 1 deletion src/main/java/Jelly/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Jelly.main.Ui;

public abstract class Command {
public boolean running() {
public boolean isRunning() {
return true;
}
public abstract void execute(TaskList taskList, Ui ui, Storage storage);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Jelly/commands/DeadlineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Jelly.main.Storage;
import Jelly.main.TaskList;
import Jelly.main.Ui;

import Jelly.task.Deadline;

public class DeadlineCommand extends Command {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Jelly/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Jelly.commands;

import Jelly.exceptions.JellyBlankMessageException;
import Jelly.main.Storage;
import Jelly.main.TaskList;
import Jelly.main.Ui;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Jelly/commands/EventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Jelly.main.Storage;
import Jelly.main.TaskList;
import Jelly.main.Ui;

import Jelly.task.Event;

public class EventCommand extends Command {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Jelly/commands/MarkCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Jelly.commands;

import Jelly.exceptions.JellyBlankMessageException;
import Jelly.main.Storage;
import Jelly.main.TaskList;
import Jelly.main.Ui;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/Jelly/commands/ToDoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Jelly.main.Storage;
import Jelly.main.TaskList;
import Jelly.main.Ui;

import Jelly.task.Todo;

public class ToDoCommand extends Command {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Jelly/commands/UnmarkCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Jelly.commands;

import Jelly.exceptions.JellyBlankMessageException;
import Jelly.main.Storage;
import Jelly.main.TaskList;
import Jelly.main.Ui;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Jelly.exceptions;


public class JellyUnknownCommandException extends JellyException {
public JellyUnknownCommandException() {
super("Oops! I really don't know what you're saying :(");
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/Jelly/main/Jelly.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package Jelly.main;

import java.util.Scanner;

import Jelly.commands.Command;
import Jelly.exceptions.JellyException;

Expand Down Expand Up @@ -48,14 +49,16 @@ public static void main(String[] args) throws JellyException {
* Runs the commands given to the Jelly Chat bot.
*/
private void run() {

ui.startUpMessage();
boolean running = true;
while (running) {
boolean isRunning = true;

while (isRunning) {
try {
String command = ui.commandMe();
Command c = Parser.parse(command);
c.execute(taskList, ui, storage);
running = c.running();
isRunning = c.isRunning();
} catch (JellyException e) {
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/Jelly/main/Parser.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package Jelly.main;

import Jelly.commands.*;
import Jelly.commands.ByeCommand;
import Jelly.commands.Command;
import Jelly.commands.DeadlineCommand;
import Jelly.commands.DeleteCommand;
import Jelly.commands.EventCommand;
import Jelly.commands.ListCommand;
import Jelly.commands.MarkCommand;
import Jelly.commands.ToDoCommand;
import Jelly.commands.UnmarkCommand;

import Jelly.exceptions.JellyBlankMessageException;
import Jelly.exceptions.JellyException;
import Jelly.exceptions.JellyUnknownCommandException;
Expand All @@ -18,8 +27,10 @@ public class Parser {
* @throws JellyException If the input is invalid.
*/
public static Command parse(String command) throws JellyException {

try {
String[] stringArray = command.split(" ");

if (stringArray[0].equals("list")) {
return new ListCommand();
} else if (stringArray[0].equals("bye")) {
Expand Down Expand Up @@ -80,6 +91,7 @@ public static Command parse(String command) throws JellyException {
String eventString = "";
String fromWhen = "";
String toWhen = "";

for (int i = 1; i < stringArray.length; i++) {
if (stringArray[i] != null) {
if (stringArray[i].equals("/from")) {
Expand All @@ -102,6 +114,7 @@ public static Command parse(String command) throws JellyException {
break;
}
}
return new EventCommand(eventString, fromWhen, toWhen);
} else if (stringArray[0].equals("delete")) {
if (stringArray.length == 1) {
throw new JellyBlankMessageException("delete");
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/Jelly/main/Storage.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package Jelly.main;

import Jelly.exceptions.JellyException;
import Jelly.task.Deadline;
import Jelly.task.Event;
import Jelly.task.Task;
import Jelly.task.Todo;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

import Jelly.exceptions.JellyException;
import Jelly.task.Deadline;
import Jelly.task.Event;
import Jelly.task.Task;
import Jelly.task.Todo;

/**
* Stores and loads tasked based on the specified file path.
*/
Expand Down Expand Up @@ -39,12 +39,15 @@ public ArrayList<Task> startUp() throws JellyException {
ArrayList<Task> storage = new ArrayList<>();
try {
File data = new File(filePath);

if (!data.exists()) {
data.getParentFile().mkdirs();
return storage;
}

int index = storage.size();
Scanner sc = new Scanner(data);

while (sc.hasNextLine()) {
String str = sc.nextLine();
String[] taskDetails = str.split(" \\| ");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/Jelly/main/TaskList.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package Jelly.main;

import Jelly.task.Task;

import java.util.ArrayList;

import Jelly.task.Task;

/**
* Contains all the commands regarding the list of tasks.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/Jelly/main/Ui.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package Jelly.main;

import Jelly.task.Task;

import java.util.ArrayList;
import java.util.Scanner;

import Jelly.task.Task;

/**
* Responsible for the interface of the Jelly Chat Bot.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/Jelly/task/Deadline.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package Jelly.task;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -56,6 +57,7 @@ public String writeToFile() {
* @return The parsed date, or null if the date is in a format that isn't accepted.
*/
protected LocalDate parseDate(String date) {

List<DateTimeFormatter> formats = new ArrayList<>();
formats.add(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
formats.add(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
Expand All @@ -65,7 +67,6 @@ protected LocalDate parseDate(String date) {
try {
return LocalDate.parse(date, formats.get(i));
} catch (DateTimeParseException e) {

}
}
return null;
Expand All @@ -78,6 +79,7 @@ protected LocalDate parseDate(String date) {
* @return The parsed date and time, or null if incorrect format.
*/
protected LocalDateTime parseDateTime(String dateTime) {

List<DateTimeFormatter> formats = new ArrayList<>();
formats.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"));
formats.add(DateTimeFormatter.ofPattern("dd/MM/yyyy HHmm"));
Expand All @@ -88,10 +90,8 @@ protected LocalDateTime parseDateTime(String dateTime) {
try {
return LocalDateTime.parse(dateTime, formats.get(i));
} catch (DateTimeParseException e) {

}
}

return null;
}
}
12 changes: 9 additions & 3 deletions src/main/java/Jelly/task/Event.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package Jelly.task;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;

import java.util.ArrayList;
import java.util.List;

Expand All @@ -14,8 +15,10 @@ public class Event extends Task {

protected String from;
protected String to;

protected LocalDate fromDate;
protected LocalDate toDate;

protected LocalDateTime fromDateTime;
protected LocalDateTime toDateTime;

Expand All @@ -38,6 +41,7 @@ public Event(String description, String from, String to) {

@Override
public String toString() {

String fromWhen = from;
String toWhen = to;

Expand All @@ -54,6 +58,7 @@ public String toString() {
}
return "[E]" + super.toString() + "(from: " + fromWhen + " to: " + toWhen + ")";
}

@Override
public String writeToFile() {
Copy link

Choose a reason for hiding this comment

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

Could be better named.
I do not expect"writeToFile" to be a method that returns the String to be written

return "E | " + (getIsDone() ? "1" : "0") + " | " + getDescription() + " | " + from + " to " + to;
Expand All @@ -66,6 +71,7 @@ public String writeToFile() {
* @return The parsed date, or null if incorrect format.
*/
protected LocalDate parseDate(String date) {

List<DateTimeFormatter> formats = new ArrayList<>();
formats.add(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
formats.add(DateTimeFormatter.ofPattern("dd/MM/yyyy"));
Expand All @@ -87,6 +93,7 @@ protected LocalDate parseDate(String date) {
* @return The parsed date and time, or null if incorrect format.
*/
protected LocalDateTime parseDateTime(String dateTime) {

List<DateTimeFormatter> formats = new ArrayList<>();
formats.add(DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm"));
formats.add(DateTimeFormatter.ofPattern("dd/MM/yyyy HHmm"));
Expand All @@ -100,7 +107,6 @@ protected LocalDateTime parseDateTime(String dateTime) {

}
}

return null;
}
}
1 change: 1 addition & 0 deletions src/main/java/Jelly/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Corresponds to a task.
*/
public class Task {

protected boolean isDone;
protected String description;

Expand Down