Skip to content

[LIU SIYI] iP#184

Open
64-1 wants to merge 56 commits into
nus-cs2113-AY2324S2:masterfrom
64-1:master
Open

[LIU SIYI] iP#184
64-1 wants to merge 56 commits into
nus-cs2113-AY2324S2:masterfrom
64-1:master

Conversation

@64-1
Copy link
Copy Markdown

@64-1 64-1 commented Feb 7, 2024

No description provided.

Copy link
Copy Markdown

@JingHaoooo JingHaoooo left a comment

Choose a reason for hiding this comment

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

Overall it looks good. Although there were some minor coding standard violations.

Comment thread src/main/java/UserDetails.java Outdated
Comment on lines +69 to +83
switch (input) {
case "1":
gender = "Male";
break;
case "2":
gender = "Female";
break;
case "3":
gender = "Other";
break;
default:
System.out.println("Invalid option selected. Please enter 1, 2, or 3.");
continue;
}
break; // Exit the loop once a valid input is received.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There should not be any indentation for case clauses to follow the coding standards.

Comment thread src/main/java/Main.java Outdated
Comment on lines +11 to +16
String message = String.format(
"Verification passed.\nOptions enabled.\n%s Born on %s\n%s\nID A.D.0013\n" +
"Rank 'S'\nListed in the Kassel Academy roster.\n" +
"Database access granted\nAccount activated\nCourse schedule generated\n" +
"I am Erii, the secretary of Kassel Academy, pleased to serve you.",
name, birthday, gender);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like the line wrapping. It makes it more readable.

Comment thread src/main/java/TaskManager.java Outdated
@@ -0,0 +1,39 @@
// TaskManager.java
public class TaskManager {
private static final String[] tasks = new String[100];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can consider setting 100 to a constant variable.

Comment thread src/main/java/TaskManager.java Outdated
public static void addTask(String task) {
if (taskCount < tasks.length) {
tasks[taskCount++] = task;
System.out.println("____________________________________________________________");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can consider changing divider to a constant.

Comment thread src/main/java/UserDetails.java Outdated
*
* @return the user's full name
*/
public static String getName() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Naming of variables are good as it follows the naming conventions of using camelCase.

Comment thread src/main/java/TaskManager.java Outdated
Comment on lines +25 to +37
public static boolean processCommand(String command) {
if ("list".equalsIgnoreCase(command)) {
listTasks();
return true;
} else if ("bye".equalsIgnoreCase(command)) {
System.out.println("____________________________________________________________");
System.out.println(" Bye. Hope to see you again soon!");
System.out.println("____________________________________________________________");
return false;
} else {
addTask(command);
return true;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good indentation

Comment thread src/main/java/UserDetails.java Outdated
Comment on lines +69 to +81
switch (input) {
case "1":
gender = "Male";
break;
case "2":
gender = "Female";
break;
case "3":
gender = "Other";
break;
default:
System.out.println("Invalid option selected. Please enter 1, 2, or 3.");
continue;
Copy link
Copy Markdown

@CXIA17 CXIA17 Feb 8, 2024

Choose a reason for hiding this comment

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

case and switch should be aligned, invalid indentation

Copy link
Copy Markdown

@hafizuddin-a hafizuddin-a left a comment

Choose a reason for hiding this comment

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

good code quality

Comment thread src/main/java/Erii.java
@@ -0,0 +1,27 @@
public class Erii {
public static void main(String[] args) {
String art =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

perhaps move this to another file?

Comment thread src/main/java/UserDetails.java Outdated
@@ -0,0 +1,88 @@
import java.util.Scanner;
import java.util.regex.Matcher;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i like that you use regex

Comment thread src/main/java/UserDetails.java Outdated
System.out.println("Please enter your full name (First Name Last Name): ");
String name;
while (true) {
name = scanner.nextLine().trim();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good using trim to remove unnecessary characters

Comment thread src/main/java/TaskManager.java Outdated
}

public static boolean processCommand(String command) {
if ("list".equalsIgnoreCase(command)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good that you have a method to ignore case

Comment thread src/main/java/Erii.java
@@ -0,0 +1,27 @@
public class Erii {
public static void main(String[] args) {
String art =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Make variable names for constant all uppercase.

Comment thread src/main/java/UserDetails.java Outdated
Comment on lines +1 to +2
import java.util.Scanner;
import java.util.regex.Matcher;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Import classes listed explicitly, good

Copy link
Copy Markdown

@sevenseasofbri sevenseasofbri 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, you can improve upon abstraction of the code. Else, well done. 👍🏽

Comment thread src/main/java/com/erii/Main.java Outdated
Comment on lines +5 to +22
// Prompt the user to enter their details
String name = UserDetails.getName();
String birthday = UserDetails.getBirthday();
String gender = UserDetails.getGenderSelection();


// Print the user details with a welcome message
String message = String.format(
"Verification passed.\nOptions enabled.\n%s Born on %s\n%s\nID A.D.0013\n" +
"Rank 'S'\nListed in the Kassel Academy roster.\n" +
"Database access granted\nAccount activated\nCourse schedule generated\n" +
"I am Erii, the secretary of Kassel Academy, pleased to serve you.",
name, birthday, gender);

System.out.println(message);

//Call control panel to start the task manager
ControlPanel.main(args);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These comments are not required as it is quite clear from the code already.


public class Erii {
public static void main(String[] args) {
String art =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

consider storing this art as a static final variable


public class TaskManager {

public enum Priority {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good use of enum

SS, S, A, B, C, D
}

public abstract class Task {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

avoid declaring multiple classes within a same file, try an separate them into differen files (to improve readability)

System.out.println("Got it. I've added this task:");
System.out.println(" " + task);
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
System.out.println("____________________________________________________________");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you can store is line as a static final variable instead

private static void addDeadlineTask(String input, TaskManager taskManager) {
String[] parts = input.split(" ?/by | ?/ ?");
if(parts.length < 3 || parts[1].isEmpty() || parts[2].isEmpty()){
System.out.println("Incorrect format. Please ensure the task description is followed by '/by' and a deadline date, and then a priority value (e.g., 'submit report /by 2021-09-30 /SS').");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

similarly here, split into 2 lines to avoid exceeding the line character limit.

}
}

private static String getAddress() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the name of this function is a little misleading perhaps? I understand it probably refers to how to 'address' someone, but maybe use a word like salutation or userTitle instead?

Comment on lines +12 to +13
private static final Scanner scanner = new Scanner(System.in);
private static final Pattern datePattern = Pattern.compile("^\\d{2}/\\d{2}/\\d{4}$");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Constant names must be all uppercase using underscore to separate words (aka SCREAMING_SNAKE_CASE).

https://se-education.org/guides/conventions/java/basic.html#naming

Comment on lines +14 to +16
private static String UserName = "";
private static String UserBirthday = "";
private static String UserGender = "";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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


public class ControlPanel {

public static void main(String[] args) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this method is really long (>30 LOC) shorten it by abstracting out parts of code into functions

https://nus-cs2113-ay2324s2.github.io/website/se-book-adapted/chapters/codeQuality.html#avoid-long-methods

64-1 and others added 30 commits February 25, 2024 17:53
Enhance event and deadline date handling with time support
Implement task search by keyword
This reverts commit 007e4ab.
(cherry picked from commit 007e4ab)
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