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

[Sim Jia Ming] iP #316

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

[Sim Jia Ming] iP #316

wants to merge 57 commits into from

Conversation

SimJM
Copy link

@SimJM SimJM commented Feb 1, 2022

Duke frees your mind of having to remember things you need to do. 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 💯

its FREE

tasklist:

  • done
  • not done

Here's the main method:

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

@SimJM SimJM changed the title Sim Jia Sim Jia Ming iP Feb 1, 2022
@SimJM SimJM changed the title Sim Jia Ming iP [Sim Jia Ming] iP Feb 1, 2022
Copy link

@tyanhan tyanhan left a comment

Choose a reason for hiding this comment

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

Good job overall, I did not notice any basic styling errors. You can improve your code by breaking down long parts into separate functions. All the best!

}

@Override
String getSym() {
Copy link

Choose a reason for hiding this comment

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

I would opt for a more intuitive name rather than sym.

Copy link

Choose a reason for hiding this comment

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

I would opt for a more intuitive name rather than sym.

Maybe you can change it to a more descriptive name such as symbol?

String phrase = sc.nextLine();
System.out.println(DASH);

if (phrase.equals("list")) {
Copy link

Choose a reason for hiding this comment

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

Perhaps you can consider using a switch statement instead?

Copy link

Choose a reason for hiding this comment

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

The code here is pretty long, but you will get to break it down later as you progress with the iP. Consider doing the printing in separate functions and get your switch statement to invoke those print functions instead.

String noOfTask = String.format("Now you have %d tasks in the list.", arrlst.size());
System.out.println(noOfTask);
}
} catch (ArrayIndexOutOfBoundsException aioobe) { // echo
Copy link

Choose a reason for hiding this comment

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

You can consider changing the parameter name to just e instead.

Copy link

@yongler yongler left a comment

Choose a reason for hiding this comment

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

LGTM! Just some minor nits to fix

@@ -0,0 +1,45 @@
public class Task {
Copy link

Choose a reason for hiding this comment

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

It is possible to change Task to an abstract class?

@@ -0,0 +1,35 @@
import java.util.ArrayList;

public class Action {
Copy link

Choose a reason for hiding this comment

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

Looks clean!

}

@Override
String getSym() {
Copy link

Choose a reason for hiding this comment

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

I would opt for a more intuitive name rather than sym.

Maybe you can change it to a more descriptive name such as symbol?

System.out.println("Hello from\n" + logo);
Scanner sc = new Scanner(System.in);
ArrayList<Task> arrlst = new ArrayList<>();
String DASH = "____________________________________________________________";
Copy link

Choose a reason for hiding this comment

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

This works too, but UI can be separated into a class for cleanliess

Copy link

@jetrz jetrz left a comment

Choose a reason for hiding this comment

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

Generally clean code, well documented, styled, and easy to understand. Only minor nitpicks in terms of documentation and code logic here and there. Well done!

Comment on lines 6 to 43
public Task(String description) {
this.description = description;
this.isDone = false;
this.sym = " ";
}

public Task(String description, String sym) {
this.description = description;
this.isDone = false;
this.sym = sym;
}

public String getStatusIcon() {
return (isDone ? "X" : " "); // mark done task with X
}

public void markAsDone() {
this.isDone = true;
System.out.println("Nice! I've marked this task as done:");
String output = String.format(" [%s][%s] %s", this.sym, this.getStatusIcon(), this.description);
System.out.println(output);
}

public void markAsNotDone() {
this.isDone = false;
System.out.println("OK, I've marked this task as not done yet:");
String output = String.format(" [%s] %s", this.getStatusIcon(), this.description);
System.out.println(output);
}

String getSym() {
return this.sym;
}

@Override
public String toString() {
return String.format("added: %s", description);
}
Copy link

Choose a reason for hiding this comment

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

Could use some javadocs documentation as Task is the parent class.

Comment on lines 79 to 88
for (int i = 1; i < arrWords.length; i++) {
if (arrWords[i].equals("/at")) {
for (int j = i + 1; j < arrWords.length; j++) {
dayAndTime = dayAndTime + " " + arrWords[j];
}
break;
} else {
remainingWords = remainingWords + " " + arrWords[i];
}
}
Copy link

Choose a reason for hiding this comment

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

Could use comments in places like these to explain what the code is doing (i.e. splitting up the user input) as it may not be apparent on first sight.

Comment on lines 21 to 28
void showList(ArrayList<Task> arrlst) {
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < arrlst.size(); i++) {
String output = String.format("%d.[%s][%s]%s\n", i + 1, arrlst.get(i).sym,
arrlst.get(i).getStatusIcon(), arrlst.get(i).description);
System.out.println(output);
}
}
Copy link

Choose a reason for hiding this comment

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

Could use a javadocs documentation.

Comment on lines 10 to 13
@Override
String getSym() {
return this.sym;
}
Copy link

Choose a reason for hiding this comment

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

May I check what is the purpose of this override? Same with deadline and todo classes. Seems redundant as the getSym() in Task is the same.

@@ -0,0 +1,45 @@
public class Task {
protected String description;
Copy link

@KwanHW KwanHW Feb 3, 2022

Choose a reason for hiding this comment

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

While protected may appear sufficient, these attributes can still be accessible by other functions once you start putting them into packages. Consider changing your attributes to private


@Override
public String toString() {
return String.format("added: %s", description);
Copy link

Choose a reason for hiding this comment

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

I think you should change your toString() method to print out the sym, isDone and description instead of this message. This can reduce code duplication in your children classes as I observed that they are using attributes in Task to form the string.

System.out.println(output);
}

String getSym() {
Copy link

Choose a reason for hiding this comment

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

Missing public keyword at function signature

@KwanHW
Copy link

KwanHW commented Feb 3, 2022

Good effort overall.

Some improvements to consider:

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

5 participants