-
Notifications
You must be signed in to change notification settings - Fork 252
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
[AY1920S1-CS2113T-W13-2] JavaCake #88
base: master
Are you sure you want to change the base?
[AY1920S1-CS2113T-W13-2] JavaCake #88
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, pretty good job and your code is quite readable.
Things to note:
- Variable names can be more descriptive.
- Remnants of Duke, especially the exceptions.
- A lot of magic numbers.
- Some methods are really long.
- Code that has been commented out can be removed.
- Make use of super class constructors and use proper
@Override
annotations.Question
and its sub-classes were really well done, you can take a look at that! - Not a lot of tests, but what you have now is a good start!
src/main/java/javacake/Parser.java
Outdated
if (input.equals("exit")) { | ||
return new ExitCommand(); | ||
} else if (input.equals("list")) { | ||
return new ListCommand(); | ||
} else if (input.equals("back")) { | ||
return new BackCommand(); | ||
} else if (input.equals("help")) { | ||
return new HelpCommand(inputCommand); | ||
} else if (input.equals("score")) { | ||
return new ScoreCommand(); | ||
} else if (input.equals("reset")) { | ||
return new ResetCommand(); | ||
} else if (input.equals("goto")) { | ||
if (inputCommand.length() <= 4) { | ||
throw new DukeException("Please specify index number in 'goto' command!"); | ||
} | ||
return new GoToCommand(inputCommand.substring(5)); | ||
} else if (input.equals("tree")) { | ||
return new MegaListCommand(); | ||
} else if (input.equals("deadline")) { | ||
return new AddCommand(inputCommand); | ||
} else { | ||
throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a better way to do this! Good attempt though, it looks neat :)
/** | ||
* Stores all files in the currentFilePath into listOfFiles. | ||
*/ | ||
public void loadFiles() throws DukeException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very long method. Look up ways to refactor code.
public ProgressStack() { | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty constructor? Look up default constructors.
String finalTrim = reducedFilePath.toString(); | ||
finalTrim = finalTrim.substring(0, finalTrim.length() - 1); | ||
return finalTrim; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finalTrim
is a very vague variable name, it could be more descriptive.
/*switch (type) { | ||
case TODO: | ||
ui.showMessage(Parser.runTodo(progressStack.getData(), input, Parser.TaskState.NOT_DONE)); | ||
storage.write(progressStack.getData()); | ||
break; | ||
case DEADLINE: | ||
ui.showMessage(Parser.runDeadline(progressStack.getData(), input, Parser.TaskState.NOT_DONE)); | ||
storage.write(progressStack.getData()); | ||
break; | ||
case EVENT: | ||
ui.showMessage(Parser.runEvent(progressStack.getData(), input, Parser.TaskState.NOT_DONE)); | ||
storage.write(progressStack.getData()); | ||
break; | ||
case DAILY: | ||
ui.showMessage(Parser.runRecurring(progressStack.getData(), input, Parser.TaskState.NOT_DONE, "daily")); | ||
storage.write(progressStack.getData()); | ||
break; | ||
case WEEKLY: | ||
ui.showMessage(Parser.runRecurring(progressStack.getData(), input, Parser.TaskState.NOT_DONE, "weekly")); | ||
storage.write(progressStack.getData()); | ||
break; | ||
case MONTHLY: | ||
ui.showMessage(Parser.runRecurring(progressStack.getData(), input, Parser.TaskState.NOT_DONE, "monthly")); | ||
storage.write(progressStack.getData()); | ||
break; | ||
default: | ||
throw new DukeException(" [Unknown COMMAND TYPE]"); | ||
}*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't leave commented out code. Just go ahead and delete unused code. Now that we are using a revision control system, we can recover any deleted code later.
/** | ||
* Constructor for profile. | ||
* @param filename String of filepath | ||
* @throws DukeException when unable to create profile | ||
*/ | ||
public Profile(String filename) throws DukeException { | ||
try { | ||
File file = new File("data/save/savefile.txt"); | ||
Duke.logger.log(Level.INFO,"Filepath: " + filepath); | ||
try { | ||
if (!file.getParentFile().getParentFile().exists()) { | ||
file.getParentFile().getParentFile().mkdir(); | ||
file.getParentFile().mkdir(); | ||
file.createNewFile(); | ||
initialiseUser(); | ||
System.out.println("A" + file.getParentFile().getParentFile().getPath()); | ||
} else if (!file.getParentFile().exists()) { | ||
file.getParentFile().mkdir(); | ||
file.createNewFile(); | ||
initialiseUser(); | ||
System.out.println("B" + file.getParentFile().getPath()); | ||
} else if (!file.exists()) { | ||
file.createNewFile(); | ||
initialiseUser(); | ||
System.out.println("C" + file.getPath()); | ||
} else { | ||
Duke.logger.log(Level.INFO, filepath + " is found!"); | ||
} | ||
|
||
} catch (IOException e) { | ||
System.out.println("before reader"); | ||
throw new DukeException("Failed to create new file"); | ||
} | ||
|
||
BufferedReader reader = new BufferedReader(new FileReader(filepath)); | ||
String line; | ||
int count = -1; | ||
while ((line = reader.readLine()) != null) { | ||
if (count == -1) { | ||
username = line; | ||
} else { | ||
topicsDone.add(Integer.parseInt(line)); | ||
} | ||
++count; | ||
} | ||
reader.close(); | ||
} catch (IOException e) { | ||
System.out.println("after reader"); | ||
throw new DukeException("Failed to close reader"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor is very lengthy.
if (!file.getParentFile().getParentFile().exists()) { | ||
file.getParentFile().getParentFile().mkdir(); | ||
file.getParentFile().mkdir(); | ||
file.createNewFile(); | ||
initialiseUser(); | ||
System.out.println("A" + file.getParentFile().getParentFile().getPath()); | ||
} else if (!file.getParentFile().exists()) { | ||
file.getParentFile().mkdir(); | ||
file.createNewFile(); | ||
initialiseUser(); | ||
System.out.println("B" + file.getParentFile().getPath()); | ||
} else if (!file.exists()) { | ||
file.createNewFile(); | ||
initialiseUser(); | ||
System.out.println("C" + file.getPath()); | ||
} else { | ||
Duke.logger.log(Level.INFO, filepath + " is found!"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good effort in keeping this neat and nicely formatted. However, having some comments here would be nice to help the developer understand your code.
if (!tasksFile.getParentFile().getParentFile().exists()) { | ||
tasksFile.getParentFile().getParentFile().mkdir(); | ||
tasksFile.getParentFile().mkdir(); | ||
tasksFile.createNewFile(); | ||
System.out.println("A" + tasksFile.getParentFile().getParentFile().getPath()); | ||
} else if (!tasksFile.getParentFile().exists()) { | ||
tasksFile.getParentFile().mkdir(); | ||
tasksFile.createNewFile(); | ||
System.out.println("B" + tasksFile.getParentFile().getPath()); | ||
} else if (!tasksFile.exists()) { | ||
tasksFile.createNewFile(); | ||
System.out.println("C" + tasksFile.getPath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good place to use a logger, as opposed to system io, since your team is already using one.
*/ | ||
public Deadline(String description, String by) throws DukeException { | ||
super(description); | ||
this.by = by; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by
is a very vague variable name.
try { | ||
setFrequency(frequency); | ||
} catch (DukeException e) { | ||
//e.getMessage(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We went through this in class. https://nuscs2113-ay1920s1.github.io/website/schedule/week6/tutorial-cs2113.html
+Resized window +Added some storage tests
error handling for files that are not named properly
v1.3: Implemented DeleteNoteCommand and refactored mainwindow
added 3 difficulity levels for quiz
v1.4 last min
@claysmilesoil @GlenWong97 @kishore03109