-
Notifications
You must be signed in to change notification settings - Fork 231
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
[CS2113-W14-1] FitNUS #16
base: master
Are you sure you want to change the base?
[CS2113-W14-1] FitNUS #16
Conversation
…-functionality Added a help command
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 good work so far with minor suggestions for your consideration. Try to avoid using magic literals e.g. magic numbers, magic strings, and create constants with meaningful names instead. Keep up with the good work.
calories = nutrients[0] * drinkVolume / 100; | ||
carbs = nutrients[1] * drinkVolume / 100; | ||
sugar = nutrients[2] * drinkVolume / 100; | ||
protein = nutrients[3] * drinkVolume / 100; | ||
fat = nutrients[4] * drinkVolume / 100; |
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.
Try to avoid magic numbers, you could consider creating a constant for "100" and give it a meaningful name, similar for magic strings as well.
System.out.println("Sorry that drink is not registered in the database."); | ||
} catch (UnregisteredMealException e) { | ||
System.out.println("Sorry that meal is not registered in the database."); | ||
} catch (invalidIndexException e) { |
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.
Class name should be in pascal form, i.e. capital i for invalid.
public void handleViewCarbohydrates() { | ||
int carbohydratesCount = 0; | ||
for (Meal meal: mealList) { | ||
carbohydratesCount += meal.getCarbs(); | ||
} | ||
for (Drink drink: drinkList) { | ||
carbohydratesCount += drink.getCarbs(); | ||
} | ||
System.out.println("Total Carbohydrates: " + carbohydratesCount); | ||
} | ||
|
||
public void handleViewProteins() { | ||
int proteinCount = 0; | ||
for (Meal meal: mealList) { | ||
proteinCount += meal.getProtein(); | ||
} | ||
for (Drink drink: drinkList) { | ||
proteinCount += drink.getProtein(); | ||
} | ||
System.out.println("Total Proteins: " + proteinCount); | ||
} | ||
|
||
public void handleViewWaterIntake() { | ||
int waterIntake = 0; | ||
for (Water water: totalWaterIntake) { | ||
waterIntake += water.getWater(); | ||
} | ||
System.out.println("Total water intake: " + waterIntake + " ml"); | ||
} | ||
|
||
public static void handleViewFiber() { | ||
int fibreCount = 0; | ||
for (Meal meal: mealList) { | ||
fibreCount += meal.getFiber(); | ||
} | ||
System.out.println("Total Fiber: " + fibreCount); | ||
} | ||
|
||
public void handleViewFat() { | ||
int fatCount = 0; | ||
for (Meal meal: mealList) { | ||
fatCount += meal.getFat(); | ||
} | ||
for (Drink drink: drinkList) { | ||
fatCount += drink.getFat(); | ||
} | ||
System.out.println("Total Fat: " + fatCount); | ||
} | ||
|
||
public void handleViewSugar() { | ||
int sugarCount = 0; | ||
for (Meal meal: mealList) { | ||
sugarCount += meal.getSugar(); | ||
} | ||
for (Drink drink: drinkList) { | ||
sugarCount += drink.getSugar(); | ||
} | ||
System.out.println("Total Sugar: " + sugarCount); | ||
} |
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.
Instead of repeating the same code with only minor changes in terms of which aspect of the composition you are interested in, you can consider abstracting further by creating a method with parameter being your interested aspect. Similar for the methods below.
System.out.println("- List entire food intake for the day: listEverything"); | ||
System.out.println("- Edit an existing meal after inserted: editMeal INDEX s/NEW_SERVING_SIZE"); | ||
System.out.println("- Edit an existing drink after inserted: editDrink INDEX s/NEW_SERVING_SIZE"); | ||
//System.out.println("- Edit water intake after inserted: editWater s/TOTAL_WATER_INTAKE"); |
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.
Remember to remove unused/commented code.
|
||
public static void parseEditMeal(String command) { | ||
int mealSizePosition = command.indexOf("/"); | ||
editMealIndex = Integer.parseInt(command.substring(9, mealSizePosition - 2).trim()) - 1; |
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.
Try to avoid magic numbers and create a constant with a meaninful name instead, e.g. offsetOne
src/main/java/seedu/fitnus/Ui.java
Outdated
System.out.println("What would you like to track today?"); | ||
Meal.printAvailableMeals(); | ||
Drink.printAvailableDrinks(); | ||
System.out.println(LINE); |
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.
Consider using the print line method created below instead.
This reverts commit b68111c.
minor fixes to Drink, Meal, Parser, User. Added exercises to exercises csv
Add JUnit for Exercises
Update developer guide
...up to 1.4.8
Edit user guide
added recommendations to view Calories and view Water
Revert "added recommendations to view Calories and view Water"
Update User Guide
...edit existing recommendation feature by Tina
Edit recommendation feature
Update DeveloperGuide
…into DG # Conflicts: # docs/DeveloperGuide.md
Finalise UG, DG and PPP
Update PPP links to page
Edit Storage Class Diagram
Resize sequence diagrams in DG
Regenerate diagrams.png
FitNUS helps NUS students keep track of their caloric intake and activities. It is optimized for CLI users so that tracking food can be done faster by typing in commands.