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

Add template command and template creation #62

Merged
merged 15 commits into from
Oct 26, 2020

Conversation

Royxuzeng
Copy link

No description provided.

@Royxuzeng Royxuzeng self-assigned this Oct 26, 2020
@Royxuzeng Royxuzeng added this to the v1.3 milestone Oct 26, 2020

public class AddTemplateCommand extends CommandForExercise{

public static final String COMMAND_WORD = "temp";

Choose a reason for hiding this comment

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

maybe better command word? Since temp can mean temporary


private final Exercise toAdd;

public AddTemplateCommand(Exercise toAdd) {

Choose a reason for hiding this comment

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

Naming with CreateTemplateCommand is similar

ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_DESCRIPTION, PREFIX_CALORIES);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_DESCRIPTION, PREFIX_CALORIES)
/*|| !argMultimap.getPreamble().isEmpty()*/) {

Choose a reason for hiding this comment

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

commented out

@@ -105,6 +107,12 @@ public void addExercise(Exercise exercise) {
updateFilteredExerciseList(PREDICATE_SHOW_ALL_EXERCISE);
}

@Override
public void createTemplate(Template template) {

Choose a reason for hiding this comment

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

createtemplate vs addtemplate: same idea, different naming? Better to use one

Copy link

@Nahoyhp Nahoyhp left a comment

Choose a reason for hiding this comment

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

Suggestions for future implementation:

  1. Create JSonTemplate class to write the file in JsonFormat
  2. Abstract out the load (which is now at TemplateList) and write (which is now at Template) to Storage class.

For now, it is fine. Best to implement for the next iteration.

return list;
}

public static Template getTemp(String name) {
Copy link

Choose a reason for hiding this comment

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

Where is this used?

FileWriter fw = new FileWriter("data/template.txt");
String textToAdd = "";

for (int i = 0; i < lists.size(); i++) {
Copy link

Choose a reason for hiding this comment

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

Better to extract this and add it to storage

@codecov-io
Copy link

Codecov Report

Merging #62 into v1.3 will decrease coverage by 3.78%.
The diff coverage is 0.75%.

Impacted file tree graph

@@             Coverage Diff              @@
##               v1.3      #62      +/-   ##
============================================
- Coverage     60.68%   56.89%   -3.79%     
  Complexity      518      518              
============================================
  Files           100      106       +6     
  Lines          1928     2058     +130     
  Branches        197      213      +16     
============================================
+ Hits           1170     1171       +1     
- Misses          672      800     +128     
- Partials         86       87       +1     
Impacted Files Coverage Δ Complexity Δ
...a/seedu/address/logic/LogicManagerForExercise.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...ddress/logic/commands/AddExerciseFromTemplate.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...edu/address/logic/commands/AddTemplateCommand.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...edu/address/logic/commands/CommandForExercise.java 100.00% <ø> (ø) 1.00 <0.00> (ø)
...a/seedu/address/logic/parser/AddCommandParser.java 92.30% <0.00%> (-7.70%) 4.00 <0.00> (ø)
...ss/logic/parser/AddExerciseFromTemplateParser.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...address/logic/parser/AddTemplateCommandParser.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...seedu/address/logic/parser/ExerciseBookParser.java 47.05% <0.00%> (-6.28%) 5.00 <0.00> (ø)
...c/main/java/seedu/address/model/ExerciseModel.java 100.00% <ø> (ø) 1.00 <0.00> (ø)
...java/seedu/address/model/ExerciseModelManager.java 65.38% <0.00%> (-4.01%) 15.00 <0.00> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f1f8ea...d93ab72. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants