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 1 commit
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
20 changes: 19 additions & 1 deletion src/main/java/Jelly/main/Jelly.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import Jelly.commands.Command;
import Jelly.exceptions.JellyException;


/**
* The main class which is responsible in running the Jelly chat bot.
*/
public class Jelly {
private static final String FILE_PATH = "./taskData/jelly.txt";
private final Scanner scanner = new Scanner(System.in);
Expand All @@ -13,6 +15,12 @@ public class Jelly {
private Ui ui;
private Storage storage;

/**
* Constructor for an instance of Jelly.
*
* @param filePath The file path used when saving or starting up the bot. Contains a list of tasks(if any).
* @throws JellyException If there are any errors while starting up Jelly.
*/
private Jelly(String filePath) throws JellyException {
this.storage = new Storage(filePath);
this.ui = new Ui();
Expand All @@ -24,11 +32,21 @@ private Jelly(String filePath) throws JellyException {
System.out.println(e.getMessage());
}
}

/**
* The main initialiser for the Jelly Chat bot.
*
* @param args
Copy link

Choose a reason for hiding this comment

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

I do not think "@param args" help much
And I believe that you do not need to document every method as well.

* @throws JellyException
*/
public static void main(String[] args) throws JellyException {
Jelly jelly = new Jelly(FILE_PATH);
jelly.run();
}

/**
* Runs the commands given to the Jelly Chat bot.
*/
private void run() {
ui.startUpMessage();
boolean running = true;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/Jelly/main/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
import Jelly.exceptions.JellyException;
import Jelly.exceptions.JellyUnknownCommandException;

/**
* Responsible for parsing commands from the user, creates a Command object.
*/
public class Parser {

/**
* Parses the command inputted.
*
* @param command The user's input etc. list, bye.
* @return An instance of Command that matches the user's input.
* @throws JellyException If the input is invalid.
*/
public static Command parse(String command) throws JellyException {
try {
String[] stringArray = command.split(" ");
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/Jelly/main/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,29 @@
import java.util.ArrayList;
import java.util.Scanner;

/**
* Stores and loads tasked based on the specified file path.
*/
public class Storage {
private static final String FILE_PATH = "./taskData/jelly.txt";

private String filePath;

/**
* Constructor for Storage, based on the specified file path.
*
* @param filePath The file path used when saving or starting up the bot. Contains a list of tasks(if any).
*/
public Storage(String filePath) {
this.filePath = filePath;
}

/**
* Starts up the Jelly Bot by loading the tasks from the specified file path.
*
* @return An ArrayList with all the tasks from the file.
* @throws JellyException If there is an error while loading up the file.
*/
public ArrayList<Task> startUp() throws JellyException {
ArrayList<Task> storage = new ArrayList<>();
try {
Expand Down Expand Up @@ -61,6 +75,11 @@ public ArrayList<Task> startUp() throws JellyException {
}
}

/**
* Saves all task data into the file.
*
* @param taskList
*/
public void saveAndExit(TaskList taskList) {
try {
FileWriter fileWriter = new FileWriter(filePath);
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/Jelly/main/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,88 @@

import java.util.ArrayList;

/**
* Contains all the commands regarding the list of tasks.
*/
public class TaskList {

private ArrayList<Task> taskList;

/**
* Constructor for a new empty tasklist.
*/
public TaskList() {
this.taskList = new ArrayList<>();
}

/**
* Constructor for a tasklist with existing tasks.
*
* @param taskList
*/
public TaskList(ArrayList<Task> taskList) {
this.taskList = taskList;
}

/**
* Gets the total number of tasks in the list.
*
* @return The number of tasks in the list.
*/
public int size() {
return taskList.size();
}

/**
* Adds a specified task into the list.
*
* @param task The task to be added into the list.
*/
public void add(Task task) {
taskList.add(task);
}

/**
* Removes the task at the specified index in the list.
*
* @param index The index of the task to be removed.
*/
public void delete(int index) {
taskList.remove(index);
}

/**
* Retrieves the task at the specified index in the list.
*
* @param index The index of the task to be retrieved.
* @return The task that was retrieved.
*/
public Task get(int index) {
return taskList.get(index);
}

/**
* Getter for the list of tasks.
* @return The list of tasks.
*/
public ArrayList<Task> getTasks() {
return taskList;
}

/**
* Marks a task at the specified index of the list, as done.
*
* @param index The index of the task to be marked as done.
*/
public void markAsDone(int index) {
taskList.get(index).markAsDone();
}

/**
* Marks a task at the specified index of the list, as not done.
*
* @param index The index of the task to be marked as not done.
*/
public void markAsUndone(int index) {
taskList.get(index).markAsUndone();
}
Expand Down
45 changes: 42 additions & 3 deletions src/main/java/Jelly/main/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,81 @@
import java.util.ArrayList;
import java.util.Scanner;

/**
* Responsible for the interface of the Jelly Chat Bot.
*/
public class Ui {
private Scanner sc;

/**
* Constructor for Ui, takes in user input from the keyboard.
*/
public Ui() {
sc = new Scanner(System.in);
}

/**
* Prints out a welcome message when the Chat Bot is booted up.
*/
public void startUpMessage() {
Copy link

Choose a reason for hiding this comment

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

sounds like a noun

System.out.println("Hello! I'm Jelly");
System.out.println("What can I do for you?");
}

/**
* Reads the command inputted by the user.
*
* @return A string of the command inputted.
*/
public String commandMe() {
return sc.nextLine();
}

/**
* If there is an error, diplay it to the user.
*
* @param message The error message.
*/
public void displayErrorMessage(String message) {
System.out.println(message);
}

/**
* Displays the list of tasks in the storage.
*
* @param storage The tasklist that is in the storage.
*/
public void printList(ArrayList<Task> storage) {
for (int i = 0; i < storage.size(); i++) {
System.out.println((i + 1) + "." + storage.get(i).toString());
}
}

public void addedTaskMessage(Task task, int noOfTasks) {
System.out.println("Ok! I've added this task: \n" + task.toString());
/**
* Displays a completion message after successfully adding a task to the list.
*
* @param addedTask The task that was added.
* @param noOfTasks The total number of tasks in the list after adding.
*/
public void addedTaskMessage(Task addedTask, int noOfTasks) {
Copy link

Choose a reason for hiding this comment

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

noun

System.out.println("Ok! I've added this task: \n" + addedTask.toString());
System.out.println("Now you have " + noOfTasks + " tasks in the list.");
}

/**
* Displays a completion message after successfully deleting a task from the list.
*
* @param deletedTask The task that was deleted.
* @param noOfTasks The total number of tasks in the list after deletion.
*/
public void deleteMessage(Task deletedTask, int noOfTasks) {
System.out.println("Okay, I've removed this task: \n" + deletedTask);
System.out.println("Now you have " + noOfTasks + " in the list.");
}


/**
* Displays a final message to the user before the Chat Bot shuts down.
*/
public void byeMessage() {
Copy link

Choose a reason for hiding this comment

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

noun

System.out.println("Bye mate! Have a nice day :]");
}
Expand Down
25 changes: 23 additions & 2 deletions src/main/java/Jelly/task/Deadline.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import java.util.ArrayList;
import java.util.List;

/**
* Corresponds to a task with a deadline(date or date and time).
*/
public class Deadline extends Task {

protected String by;
Expand All @@ -15,6 +18,12 @@ public class Deadline extends Task {

protected LocalDateTime deadLineDateAndTime;

/**
* Constructor for a deadline task.
*
* @param description The description of the task.
* @param by When the task is due by.
*/
public Deadline(String description, String by) {
super(description);
this.deadlineDate = parseDate(by);
Expand All @@ -40,6 +49,12 @@ public String writeToFile() {
return printedStuff + this.by;
}

/**
* Parses the date inputted that corresponds to the formats accepted.
*
* @param date The due date of the task.
* @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"));
Expand All @@ -56,7 +71,13 @@ protected LocalDate parseDate(String date) {
return null;
}

protected LocalDateTime parseDateTime(String date) {
/**
* Parses the date and time inputted that corresponds to the formats accepted.
*
* @param dateTime The due date and time of the task.
* @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 @@ -65,7 +86,7 @@ protected LocalDateTime parseDateTime(String date) {

for (int i = 0; i < formats.size(); i++) {
try {
return LocalDateTime.parse(date, formats.get(i));
return LocalDateTime.parse(dateTime, formats.get(i));
} catch (DateTimeParseException e) {

}
Expand Down
Loading