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

[butteredyakiimo] iP #525

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

Conversation

butteredyakiimo
Copy link

@butteredyakiimo butteredyakiimo commented Sep 3, 2023

BUTTER

"Tracking your tasks will be as smooth as butter. 🧈"

BUTTER helps you remember what you need to do. It's,

  • text-based
  • easy to use
  • FAST SUPER FAST to use

All you need to do is,

  1. download it from here.
  2. double click it.
  3. add your tasks.
  4. let it manage your tasks for you!

And it is FREE!

Features:

  • Managing tasks
  • Managing deadlines
  • Managing events
  • Searching for tasks
  • Reminders (coming soon)

If you are a Java programmer, you can use it to practise Java too. Here's the main method:

public static void main(String[] args) {
        new Duke("./data/duke.txt").run();
    }

damithc and others added 30 commits August 9, 2023 02:16
@@ -15,3 +15,5 @@ bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT

/src/main/java/*.class
Copy link

Choose a reason for hiding this comment

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

Looks good to me 😄

Copy link

@antonTan96 antonTan96 left a comment

Choose a reason for hiding this comment

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

LGTM! There could be some parts that can be optimized but it's a great effort overall

Comment on lines 38 to 42
if (parser.isGoodbye(input)) {
break;
} else {
parser.parseInput(input);
}

Choose a reason for hiding this comment

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

The way you check for a terminating condition is quite intuitive by checking whether the input is "bye" or not. However, this involves throwing the input into the parser twice. Would it be better to let the parser handle the case "bye" in parser.parseInput(input) ?

Comment on lines 37 to 39
private static boolean isNumber(String s) {
return s != null && s.matches("[0-9.]+");
}

Choose a reason for hiding this comment

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

I like how regex is used here :D

Comment on lines 142 to 154
if (inputArr.length == 1) {
throw new NoTaskIdException();
} else {
String strIndex = inputArr[1];
if (isNumber(strIndex)) {
int index = Integer.parseInt(strIndex) - 1; //because index starts from 1
if (tasks.isValidTaskId(index)) {
tasks.markTask(index);
}
} else {
throw new InvalidTaskIdException();
}
}

Choose a reason for hiding this comment

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

What happens if tasks.isValidTaskId(index) returns false? Could InvalidTaskIdException be thrown? I would write this part like this:

        if (inputArr.length == 1) {
            throw new NoTaskIdException();
        } else {
            String strIndex = inputArr[1];
            if (isNumber(strIndex) && tasks.isValidTaskId(Integer.parseInt(strIndex) - 1)) {
                int index = Integer.parseInt(strIndex) - 1; //because index starts from 1
                
                tasks.markTask(index);
                
            } else {
                throw new InvalidTaskIdException();
            }
        }

Comment on lines 168 to 180
if (inputs.length == 1) {
throw new NoTaskIdException();
} else {
String strIndex = inputs[1];
if (isNumber(strIndex)) {
int index = Integer.parseInt(strIndex) - 1; //because index starts from 1
if (tasks.isValidTaskId(index)) {
tasks.unMarkTask(index);
}
} else {
throw new InvalidTaskIdException();
}
}

Choose a reason for hiding this comment

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

Same question as mentioned above

Comment on lines 216 to 240
if (inputs.length == 1) {
throw new NoDescException();
} else {
String afterCommand = inputs[1];
String[] details = afterCommand.split(" /by ", 2);

if (details.length < 2) {
throw new InvalidDeadlineException();
} else {
String desc = details[0];
String date = details[1];

if (desc.isEmpty()) {
throw new NoDescException();
} else {
try {
LocalDateTime dateTime = convertToDateTime(date);
Deadline deadline = new Deadline(0, desc, dateTime);
tasks.addTask(deadline);
} catch (DateTimeParseException e) {
ui.showInvalidDateFormat();
}
}
}
}

Choose a reason for hiding this comment

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

This part is quite heavily nested. Could you try to refactor the code to make it more flatter?

Comment on lines 255 to 300
public void parseEvent(String input) throws NoDescException, NoStartException, NoEndException,
InvalidStartEndException, InvalidEventException {
String[] inputs = input.split(" ", 2);
if (inputs.length == 1) {
throw new NoDescException();
} else if (inputs[1].isBlank()) {
throw new NoDescException();
} else {
String afterCommand = inputs[1];
String[] details = afterCommand.split(" /from ", 2);

if (details[0].isBlank()) {
throw new NoDescException();
} else if (details.length == 1) {
throw new InvalidEventException();
} else {
String task = details[0];
String start = details[1].split(" /to ", 2)[0];

if (start.isBlank()) {
throw new NoStartException();
} else {
String[] endDetails = afterCommand.split(" /to ", 2);

if (endDetails.length == 1) { //no end date added
throw new NoEndException();
} else {
String end = endDetails[1];

if (end.isBlank()) {
throw new NoEndException();
} else {
try {
LocalDateTime startDateTime = convertToDateTime(start);
LocalDateTime endDateTime = convertToDateTime(end);
Event event = new Event(0, task, startDateTime, endDateTime);
tasks.addTask(event);
} catch (DateTimeParseException e) {
ui.showInvalidDateFormat();
}
}
}
}
}
}
}

Choose a reason for hiding this comment

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

Same question with this method.

dataFile = createDataFile();
}

//create a FileWriter object to write to file. Note that this overwrites the existing data!

Choose a reason for hiding this comment

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

I like this warning for i have fallen for this so many times D:
I still don't know how FileWriters work

butteredyakiimo and others added 24 commits September 8, 2023 01:05
Assertions help to detect possible bugs, as they
verify certain assumptions that the code makes.
Gradle run is also configured to enable assertions.
Some methods are extremely long, and have more than one
level of abstraction. Magic numbers are used to describe
the task status.

Let's make more methods to adhere to SLAP and avoid nested code,
and also create a new Enum to make code easier to understand.
Modify code to adhere to code quality standards
Currently, users only have a list commmand to list all the tasks.

To create reminders for upcoming tasks, users need to be able to view
the tasks that are due before/within the time period.

A flag can be used at the end of the list command of the format:
'list flag'. The time period for both deadline and event starts at the
start of the day at 00:00. The end is determined by the flag indicated
by the user.

Let's add the following flags:
* 'today' : lists all tasks that in the period today 00:00 to tmr 00:00
* 'week' : lists all tasks that are in the period today 00:00 to one
week later 00:00
* 'fort': lists all tasks that are in the period today 00:00 to 2 weeks
later 00:00
Currently, users only have a list commmand to list all the tasks.

To create reminders for upcoming tasks, users need to be able to view
the tasks that are due before/within the time period.

A flag can be used at the end of the list command of the format:
'list flag'. The time period for both deadline and event starts at the
start of the day at 00:00. The end is determined by the flag indicated
by the user.

Let's add the following flags:
* 'today' : lists all tasks that in the period today 00:00 to tmr 00:00
* 'week' : lists all tasks that are in the period today 00:00 to one
week later 00:00
* 'fort': lists all tasks that are in the period today 00:00 to 2 weeks
later 00:00
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.

5 participants