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

[CS2113-W14-1] FitNUS #16

Open
wants to merge 426 commits into
base: master
Choose a base branch
from

Conversation

edwardhumi
Copy link

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.

JeffinsonDarmawan added a commit to JeffinsonDarmawan/tp that referenced this pull request Mar 14, 2024
Copy link

@wenxin-c wenxin-c left a 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.

Comment on lines 31 to 35
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;

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) {

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.

Comment on lines 68 to 126
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);
}

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");

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;

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

System.out.println("What would you like to track today?");
Meal.printAvailableMeals();
Drink.printAvailableDrinks();
System.out.println(LINE);

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.

jasonlienardi and others added 28 commits April 1, 2024 18:58
minor fixes to Drink, Meal, Parser, User. Added exercises to exercises csv
...up to 1.4.8
added recommendations to view Calories and view Water
Revert "added recommendations to view Calories and view Water"
...edit existing recommendation feature by Tina
edwardhumi and others added 30 commits April 15, 2024 20:24
…into DG

# Conflicts:
#	docs/DeveloperGuide.md
Finalise UG, DG and PPP
Update PPP links to page
...amend the images file route.
Edit Storage Class Diagram
Resize sequence diagrams in DG
Regenerate diagrams.png
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.

9 participants