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

[Caesar Pang] Duke Increments #350

Open
wants to merge 60 commits into
base: master
Choose a base branch
from

Conversation

caesarpjz
Copy link

Duke Increments

j-lum and others added 27 commits August 6, 2019 15:25
Add toolVersion block in to Gradle code sample to prevent errors.
# Conflicts:
#	src/main/java/Duke.class
#	src/main/java/Duke.java
#	src/main/java/Task.class
#	src/main/java/Task.java

Have completed all merge conflicts. This is the final draft for lvl 7 and lvl 8.
# Conflicts:
#	src/main/java/Event.class
#	src/main/java/Event.java
#	src/main/java/Storage.java
#	src/main/java/Task.class
#	src/main/java/TaskList.class
#	src/main/java/Todo.class
#	src/main/java/Todo.java
# Conflicts:
#	src/main/java/Ui.class
/**
* Main method.
*/
public static void main(String[] args) throws IOException{
Copy link

Choose a reason for hiding this comment

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

I think this is a bad practice. You should probably catch the IOException somewhere within your code, rather than just throwing it from your main method.

*/
@Override
public String toString() {
String date = formatDate(when);
Copy link

Choose a reason for hiding this comment

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

You may want to consider storing this formatted date as a variable, so you don't have to keep converting it all the time.

protected static ArrayList<Task> taskList = new ArrayList<Task>();
protected static String file = "todo.txt";

public Storage(String file) {
Copy link

Choose a reason for hiding this comment

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

You should consider removing this parameter, since it doesn't seem to do anything.

protected static ArrayList<Task> taskList = new ArrayList<Task>();
protected static String file = "todo.txt";

public Storage(String file) {
Copy link

Choose a reason for hiding this comment

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

You should consider removing this parameter, since it doesn't seem to do anything.

*/
public void addToFile(String filepath, String textToAdd) throws IOException {
FileWriter typer = new FileWriter(filepath, true);
typer.write(textToAdd + System.lineSeparator());
Copy link

Choose a reason for hiding this comment

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

Have to say that I didn't know about this System.lineSeparator() function. Looks like it might be useful for a cross-platform application. Good job 👍👍

*/
public static int countLines(String filename) throws IOException {
try (InputStream inputs = new BufferedInputStream(new FileInputStream(filename))) {
byte[] characters = new byte[1024];
Copy link

Choose a reason for hiding this comment

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

Just curious, is there a reason you chose to use byte rather than char?

* does not exist but cannot be created, or cannot be opened for any other reason.
*/
public void deleteCommand(String text) throws IOException {
int num = text.indexOf(" ");
Copy link

Choose a reason for hiding this comment

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

Maybe this variable can be named better?

@LeowWB
Copy link

LeowWB commented Sep 4, 2019

Overall, I think you did a great job with the documentation. I didn't notice any public functions missing JavaDoc comments. Good work 👍

Copy link

@jon-chua jon-chua left a comment

Choose a reason for hiding this comment

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

Your code is very well-documented 👍
As mentioned, I think it would be a good idea to abstract out parsing-related functionality to the Parser class.
On another note, your printed messages were interesting and useful 😄
Implementing more tests would prevent regressions from being introduced in the future too!

int index = task.indexOf("[");
String taskType = task.substring(index + 1, index + 2);
int spaceIndex = task.indexOf(" ");
switch (taskType) {
Copy link

Choose a reason for hiding this comment

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

There's a specific convention to follow for switch statements! https://nus-cs2103-ay1920s1.github.io/website/coding-standards/java/intermediate.html

@@ -0,0 +1,167 @@
import java.io.IOException;
import java.sql.SQLOutput;
Copy link

Choose a reason for hiding this comment

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

This seems like an unused import.

* @throws IOException If the named file exists but is a directory rather than a regular file,
* does not exist but cannot be created, or cannot be opened for any other reason.
*/
public void eventCommand(String text) throws DukeException, IOException {
Copy link

Choose a reason for hiding this comment

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

I think the parsing of the String should be moved to the Parser class, the TaskList class should be concerned with the operations on the list itself.

* @throws IOException If the named file exists but is a directory rather than a regular file,
* does not exist but cannot be created, or cannot be opened for any other reason.
*/
public void deadlineCommand(String text) throws DukeException, IOException {
Copy link

Choose a reason for hiding this comment

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

Similar to eventCommand, the parsing can be abstracted out to the Parser class.

* command based on the input. Prints out error messages as well.
*/
public void nextCommand() {
while (scan.hasNext()) {
Copy link

Choose a reason for hiding this comment

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

I think we should try to use the Parser class you have created to parse the input first! This way we can abstract out the parsing functions and so the UI class can just be concerned with the UI tasks.

Copy link

@groot0x12 groot0x12 left a comment

Choose a reason for hiding this comment

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

Hi! You might want to clean up your repository by avoiding pushing your class files or just do a repository refactor. Overall, great effort but you might want to do more javadocs and documentation because it was a bit hard to understand the intention behind your code :)

@@ -0,0 +1,15 @@
public class Command {

Choose a reason for hiding this comment

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

I feel that this is a plausible solution but you might want to consider abstract classes as a more efficient way of inheritance for all your other command sub-classes.


public String nextCommand(String input) {
String text = input;
switch ()

Choose a reason for hiding this comment

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

Missing documentation and code looks incomplete. Missing a return statement as well. I'm guessing what you're trying to do here is abstract the Command class to have some form of inheritance, instead of using methods to facilitate your commands. You're on the right track, just add more to this switch statement.

}


public static String dateFormatter(String text) {

Choose a reason for hiding this comment

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

This is definitely a plausible solution to obtaining substrings from the command. However, you might want to consider using the java String.split() method to make obtaining your data more efficient!

import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

public class Duke extends Application {

Choose a reason for hiding this comment

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

You might want to consider using multiple classes to facilitate your JavaFX GUI (MainWindow.java / DialogBox.java etc.)
Having all the code in your Duke.java makes it very messy and unreadable.

ui.printIndent();
switch (text) {
case "todo":
throw new DukeException("☹ OOPS!!! The description of a todo cannot be empty. "

Choose a reason for hiding this comment

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

Your error format can be stored in a string variable so that it's easy to reuse.

String formatted = date;
if (!date.contains(")")) {
try {
Date d = new SimpleDateFormat("dd/MM/yyyy hhmm").parse(date);

Choose a reason for hiding this comment

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

Great effort in handling date and time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants