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

[Rehad A] iP #474

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

[Rehad A] iP #474

wants to merge 50 commits into from

Conversation

rehad-a
Copy link

@rehad-a rehad-a commented Aug 26, 2021

Duke

"Your mind is for having ideas, not holding them." - David Allen (source)

Duke helps you in managing and organizing your tasks. It's,

  • text-based
  • easy to learn
  • 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's FREE! 🥳 🎉

Features:

  • Managing tasks 📝
  • Managing deadlines (coming soon) 📅
  • Reminders (coming soon) 🔔

If you're a Java programmer, you can use it to practice Java too. Here's main method:

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

@rehad-a rehad-a changed the title [Rehad A] [Rehad A] iP Aug 26, 2021
src/main/java/DeadlineTask.class
src/main/java/Duke.class
src/main/java/EventTask.class
src/main/java/Task.class

Choose a reason for hiding this comment

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

Should this be simplified as src/main/java/*.class to make the file less verbose ?


public DeadlineTask(String description, String time) {
super(description);
this.type = "D";

Choose a reason for hiding this comment

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

Should we remove this as these variables are not shadowed

public class Duke {
public static void main(String[] args) {
public static void loadTasksFromFile(ArrayList<Task> tasks) throws IOException, DukeException {
String directoryPath = "./data";

Choose a reason for hiding this comment

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

Should we add visibility modifier such as private for these variables

@@ -1,10 +1,166 @@
import jdk.jfr.Event;

Choose a reason for hiding this comment

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

Is this unused imports ?

Scanner f = new Scanner(dataFile);

while (f.hasNext()) {
String[] task = f.nextLine().split("|");

Choose a reason for hiding this comment

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

Should we use plural form for task

System.out.printf("%d.%s\n", i + 1, tasks.get(i));
}
System.out.println(line);
}else if (command.contains("delete")) {

Choose a reason for hiding this comment

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

Should we fix the spacing here ?

int taskIdxStart = command.indexOf(" ") + 1;
String task = command.substring(taskIdxStart);
tasks.add(new TodoTask(task));
System.out.printf("%sGot it. I've added this task:\n%s\nNow you have %d tasks in the list\n%s\n", line, tasks.get(ctr), ctr + 1, line);

Choose a reason for hiding this comment

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

Should we separate this into 2 lines, as 1 line has max of 120 chars

}

public static void saveTasksToFile(ArrayList<Task> tasks) throws IOException {
FileWriter fw = new FileWriter("./data/duke.txt");

Choose a reason for hiding this comment

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

Really nice use of file writer btw! just one suggestion you can check try-with-resources

Copy link

@simonjulianl simonjulianl left a comment

Choose a reason for hiding this comment

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

Overall pretty clean code and functional! Just maybe more spacing and newlines so that people can read it easier

Copy link

@yyhangz yyhangz left a comment

Choose a reason for hiding this comment

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

Great implementation overall!

Comment on lines 95 to 99
try {
if (command.contains("done")) {
if (!command.contains(" ")) {
throw new DukeException("OOPS!! done needs the index of the task.");
}
Copy link

Choose a reason for hiding this comment

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

Should we use an alternative implementation that reduces nesting?

System.out.println(line + "Hello I'm Duke\nWhat can I do for you?\n" + line);

ArrayList<Task> tasks = new ArrayList<>(100);
int ctr = 0;
Copy link

Choose a reason for hiding this comment

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

Should we use a name that is more semantically appropriate for the variable?

Comment on lines 6 to 12
this.type = "E";
this.time = time;
}

public EventTask(String description, boolean isDone, String time) {
super(description, isDone);
this.type = "E";
Copy link

Choose a reason for hiding this comment

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

Seems like there is repetition in the assignment of this.type = "E". Perhaps this could be abstracted for ease of refactoring in the future?

String taskType = task[0];
boolean isDone = (Integer.parseInt(task[1]) == 1);
String description = task[2];
String time = task.length == 4 ? task[3] : null;
Copy link

Choose a reason for hiding this comment

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

Perhaps 4 could be defined as a class level constant to avoid the use of magic literals?

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.

3 participants