Skip to content

[Li Shunyang/lishunyang12] ip#196

Open
lishunyang12 wants to merge 23 commits into
nus-cs2113-AY2425S2:masterfrom
lishunyang12:master
Open

[Li Shunyang/lishunyang12] ip#196
lishunyang12 wants to merge 23 commits into
nus-cs2113-AY2425S2:masterfrom
lishunyang12:master

Conversation

@lishunyang12
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@HalFentise HalFentise left a comment

Choose a reason for hiding this comment

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

i like your implementation in task class

@lishunyang12
Copy link
Copy Markdown
Author

i like your implementation in task class

thanks

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 so far! Some methods are a little long but those can be refactored to improve readability.

Comment thread src/main/java/Engineer/Engineer.java Outdated
Comment on lines +4 to +5
import engineer.task.*;
import engineer.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.

Avoid using wildcard imports, explicitly import each class

static TextDivider myTextDivider = new TextDivider();

public static void printResponse() throws EngineerException{
boolean isKeepAsking = 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.

Think of the name of a boolean variable as a question. I am not quite sure if "is keep asking?" a good name in this case?
Maybe something like isRunning or shouldContinue would be more grammartically sound?

Comment on lines +20 to +22
if (inputMessage.isEmpty()) {
throw new EngineerException(myChatBotManager.askForNonEmptyValue());
}
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 job making the happy path prominent.

static ChatBotManager myChatBotManager = new ChatBotManager();
static TextDivider myTextDivider = new TextDivider();

public static void printResponse() throws EngineerException{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Few things about this method

  1. The method is quite long (>30LOC). Consider chunking it into multiple methods to maintain redability
  2. The naming is not apt because it is not only printing the response but doing several other tasks within it.

public class ChatBotManager {
private String indent = " ";
private String line = indent + "___________________________";
// TaskManager myTaskManager = new TaskManager();
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 commenting out dead code. Just delete it instead

Comment on lines +28 to +55
public String[] divideEvent(String[] words){
String inputTaskEvents = "";
String from = "";
String to = "";
String[] textString = new String[3];

int firstDivisionIndex = 0;
int secondDivisionIndex = 0;
for(int i = 0; i < words.length; i++) {
if(words[i].equals("/from")) {
firstDivisionIndex = i;
}
if(words[i].equals("/to")) {
secondDivisionIndex = i;
}
}
for(int i = 0; i < firstDivisionIndex; i++) {
inputTaskEvents += words[i] + " ";
}
for(int i = firstDivisionIndex+1; i < secondDivisionIndex; i++) {
from += words[i] + " ";
}
for(int i = secondDivisionIndex+1; i < words.length; i++) {
if(i == words.length-1) {
to += words[i];
} else {
to += words[i] + " ";
}
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 using magic literals by using constants or variables in place of them

Comment on lines +125 to +134
List<String> lines = Files.readAllLines(Paths.get(FILE_PATH));
for (String line : lines) {
if(!line.trim().isEmpty()) {
Task task = Task.fromFileString(line);
if(task != null) {
taskList.add(task);
taskCount++;
}
}
}
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 is around 3 levels of indentation, consdier moving the inner lines into a separate method

writer.write(taskList.get(i).toFileString() + "\n");
}
writer.close();
}catch(IOException e) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
}catch(IOException e) {
} catch(IOException e) {

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