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

[gitsac] iP #180

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

[gitsac] iP #180

wants to merge 56 commits into from

Conversation

gitsac
Copy link

@gitsac gitsac commented Jan 24, 2023

Knight

"Now, your mind can forget what's to be done, for I will remember it for you." - Knight

Knight frees you from life's smallest worries, by remembering all the tasks you need to do. It's:

  • text-based
  • easy to learn
  • incredibly efficient when proficient

Setting you up for success

Ready to remember less things, and start doing more?
All you need to do is,

  • download it from here.
  • open a command window in the same directory
  • using the command window, type the following command:
    java -jar Duke.jar
  • add your tasks.
  • let it manage your tasks for you 😉

And it is FREE!

Features:

  • Managing tasks
  • Managing deadlines
  • Reminders (coming soon)

If you happen to do a little coding in Java, see if this makes sense to you:

public class Main {
    public static void main(String[] args) {
        Application.launch(MainApp.class, args);
    }
}

@gitsac gitsac changed the title gitsac iP [gitsac] iP Jan 24, 2023
# Conflicts:
#	src/main/java/Duke.java
#	src/main/java/duke/Parser.java
#	src/main/java/duke/TaskList.java
#	src/main/java/duke/Ui.java
#	src/main/java/duke/tasktypes/Deadlines.java
Copy link

@wz2k wz2k left a comment

Choose a reason for hiding this comment

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

Overall, I can see that you have put in a lot of efforts to verify inputs. Just need to address some small changes to your code. Keep up the good work! 👍

Comment on lines 1 to 3
1.[T][X] test2
2.[T][X] foru
3.[D][X] forum enjoyer (by: Tuesday)
Copy link

Choose a reason for hiding this comment

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

You seem to have 2 data text file and folder. Just a reminder to double check you file path and delete the redundant folder

src/main/java/duke/DukeExceptions.java Outdated Show resolved Hide resolved
Comment on lines 24 to 35
if (printThisOut.equals("Wrong size for mark/unmark")) {
toReturn = ":( Sorry, the number input is wrong. Please check the possible indexes again using list!";
}
if (printThisOut.equals("deadline") || printThisOut.equals("todo")) {
toReturn = ":( Sorry, the description of a " + this.printThisOut + " cannot be empty!";
}
if (printThisOut.equals("event")) {
toReturn = ":( Sorry, the description of an " + this.printThisOut + " cannot be empty!";
}
if (printThisOut.equals("find")) {
toReturn = ":( Sorry, please input a keyword!";
}
Copy link

Choose a reason for hiding this comment

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

Possible to use a switch statement here with fall through for deadline and todo but this is up to you.

Comment on lines 24 to 67
if (input.startsWith("todo")) {
handleToDoTask(input, listOfTasks);
return;
}

if (input.startsWith("find")) {
handleFindTask(input, listOfTasks);
return;
}

if (input.startsWith("deadline")) {
handleDeadlineTask(input, listOfTasks);
return;
}

if (input.startsWith("event")) {
handleEventTask(input, listOfTasks);
return;
}

if (input.equals("list")) {
handleList(listOfTasks);
return;
}

if (input.startsWith("delete")) {
handleDelete(input, listOfTasks);
return;
}

if (input.startsWith("checkdue")) {
handleCheckDue(input, listOfTasks);
return;
}

if (input.startsWith("mark")) {
handleMark(input, listOfTasks);
return;
}

if (input.startsWith("unmark")) {
handleUnmark(input, listOfTasks);
return;
}
Copy link

Choose a reason for hiding this comment

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

One way to use 'startsWith' together with a switch statement is to use the split method.

src/main/java/duke/Parser.java Outdated Show resolved Hide resolved
Comment on lines 1 to 31
package duke;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

/**
* Class used to read user's input for Duke chatbot.
*/
public class Ui {

protected BufferedReader readingInput;

/**
* Constructor to initiate a bufferedreader to get user input.
*/
public Ui() {
this.readingInput = new BufferedReader(new InputStreamReader(System.in));
}

/**
* Function to read user input.
* @return String representation of user input.
* @throws IOException
*/
public String gettingUserInput() throws IOException {
String userInput = readingInput.readLine();
return userInput;
}

}
Copy link

Choose a reason for hiding this comment

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

Perhaps all you printing of messages could also be handled by the UI class

/**
* Class which represents a Task with a deadline.
*/
public class Deadlines extends Task {
Copy link

Choose a reason for hiding this comment

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

Perhaps it is better to name is in singular form as each object from this class is a singular deadline.

src/main/java/duke/tasktypes/Deadlines.java Outdated Show resolved Hide resolved
* @return String representation of deadline task.
*/
@Override
public String toString() {
Copy link

Choose a reason for hiding this comment

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

Try to keep methods to a limit of 30 lines if possible

src/main/java/duke/tasktypes/Task.java Outdated Show resolved Hide resolved
src/main/java/Duke.java Outdated Show resolved Hide resolved
*/
public class DukeExceptions extends Exception {
protected String printThisOut;

Copy link

Choose a reason for hiding this comment

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

Better to use a variable name like toPrint

Copy link

Choose a reason for hiding this comment

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

Also better to call your exception DukeException

import duke.tasktypes.Events;
import duke.tasktypes.ToDo;
import duke.tasktypes.Task;

Copy link

Choose a reason for hiding this comment

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

Great use of packages!

scannerForFileData.close();
return useThis;
}

Copy link

Choose a reason for hiding this comment

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

Might need to consider corrupted files and handle them gracefully

toPrint = "Got it. I've added this task:\n " + toAdd.toString() + "\nNow you have " + listOfTasks.size() + " tasks in the list.";
}
System.out.println(toPrint);
}
Copy link

Choose a reason for hiding this comment

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

Printing listOfTasks.size() should be abstracted out to a function. Now there is a lot of repeated code. The function could also take in a boolean parameter isPlural for that extra "s" case

return this.name;
}

}
Copy link

Choose a reason for hiding this comment

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

Task should be responsible for printing the [X] as this is repeated across all subclasses

gitsac and others added 24 commits February 4, 2023 00:28
In many methods, it is assumed that certain variables or objects
are of a certain state.

By using assertions, code quality can be improved to make those
assumptions a guarantee.

Assumptions make it difficult to debug if the error
stack trace is very long.

It is important to hold assumptions in current state as otherwise
there will be a need to check for many things at all methods.

Let's improve code quality and make debugging easier by adding
assumptions.
The code body is functioning well but makes for poor reading at
times due to issues like big chunks of code and deep nesting.

By abstracting deep nesting and big chunks of code
into multiple helper functions, the code becomes more readable.

Let's practice SLAP and be mindful of readability in the future.
Improve code quality by refactoring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants