Skip to content

Commit

Permalink
Merge pull request #59 from MustafaAH10/branch-Mustafa
Browse files Browse the repository at this point in the history
Branch mustafa
  • Loading branch information
MustafaAH10 authored Mar 14, 2023
2 parents e712a2b + b1590c2 commit 555023b
Show file tree
Hide file tree
Showing 35 changed files with 160 additions and 125 deletions.
16 changes: 8 additions & 8 deletions src/main/java/seedu/Commands/AddMealCommand.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package seedu.Commands;
package seedu.commands;

import java.util.ArrayList;
import java.util.List;
import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Entities.Food;
import seedu.Entities.Meal;
import seedu.Exceptions.LifeTrackerException;
import seedu.Ui.GeneralUi;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.entities.Food;
import seedu.entities.Meal;
import seedu.exceptions.LifeTrackerException;
import seedu.ui.GeneralUi;

public class AddMealCommand extends Command {
@Override
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/Commands/Command.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package seedu.Commands;
package seedu.commands;

import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Exceptions.LifeTrackerException;
import seedu.Ui.GeneralUi;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.exceptions.LifeTrackerException;
import seedu.ui.GeneralUi;

public abstract class Command {
private boolean isExit;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/Commands/DeleteMealCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package seedu.Commands;
package seedu.commands;

import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Entities.Meal;
import seedu.Exceptions.InvalidCommandException;
import seedu.Exceptions.LifeTrackerException;
import seedu.Ui.GeneralUi;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.entities.Meal;
import seedu.exceptions.InvalidCommandException;
import seedu.exceptions.LifeTrackerException;
import seedu.ui.GeneralUi;

public class DeleteMealCommand extends Command{
private int index;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/Commands/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package seedu.Commands;
package seedu.commands;

import java.io.IOException;

import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Exceptions.LifeTrackerException;
import seedu.Ui.GeneralUi;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.exceptions.LifeTrackerException;
import seedu.ui.GeneralUi;

public class ExitCommand extends Command{
@Override
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/seedu/Commands/ListCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package seedu.Commands;
package seedu.commands;

import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Exceptions.LifeTrackerException;
import seedu.Exceptions.InvalidArgumentsException;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.exceptions.LifeTrackerException;
import seedu.exceptions.InvalidArgumentsException;
//import seedu.Output.UI;
import seedu.Ui.GeneralUi;
import seedu.ui.GeneralUi;

public class ListCommand extends Command {
private String argument;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/seedu/Commands/UpdateUserCommand.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package seedu.Commands;
package seedu.commands;

import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Entities.User;
import seedu.Exceptions.LifeTrackerException;
import seedu.Ui.GeneralUi;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.entities.User;
import seedu.exceptions.LifeTrackerException;
import seedu.ui.GeneralUi;

public class UpdateUserCommand extends Command {
public String updateName(GeneralUi ui) {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/seedu/Commands/ViewUserCommand.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package seedu.Commands;
package seedu.commands;

import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Entities.CaloricIntake;
import seedu.Entities.User;
import seedu.Exceptions.LifeTrackerException;
import seedu.Ui.GeneralUi;
import seedu.Ui.CalorieUi;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.entities.CaloricIntake;
import seedu.entities.User;
import seedu.exceptions.LifeTrackerException;
import seedu.ui.GeneralUi;
import seedu.ui.CalorieUi;


public class ViewUserCommand extends Command {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Database/FileReadable.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Database;
package seedu.database;

import java.io.IOException;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Database/FileWritable.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Database;
package seedu.database;

import java.io.IOException;

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/Database/FoodStorage.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Database;
package seedu.database;

import java.io.BufferedReader;
import java.io.FileReader;
Expand All @@ -7,11 +7,11 @@
import java.util.List;
import java.util.stream.Collectors;

import seedu.Definitions.FoodTypes;
import seedu.Entities.Dish;
import seedu.Entities.Food;
import seedu.Entities.Ingredient;
import seedu.Entities.Side;
import seedu.definitions.FoodTypes;
import seedu.entities.Dish;
import seedu.entities.Food;
import seedu.entities.Ingredient;
import seedu.entities.Side;

public class FoodStorage extends Storage implements FileReadable {
private static final String csvDelimiter = ",";
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/seedu/Database/MealStorage.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package seedu.Database;
package seedu.database;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import seedu.Entities.Meal;
import seedu.Entities.Food;
import seedu.entities.Meal;
import seedu.entities.Food;
import com.opencsv.CSVWriter;

public class MealStorage extends Storage implements FileReadable, FileWritable {
Expand Down Expand Up @@ -35,8 +35,7 @@ public void write() throws IOException {
CSVWriter.RFC4180_LINE_END);
String[] header = { "Date", "Foods" };
writer.writeNext(header);
for (Meal meal : meals)
{
for (Meal meal : meals) {
writer.writeNext(meal.toWriteFormat(foodsDelimiter));
}
writer.close();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Database/Storage.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Database;
package seedu.database;

public abstract class Storage {
protected String filePath;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/Database/UserStorage.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Database;
package seedu.database;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -8,7 +8,7 @@
import java.io.IOException;

import com.opencsv.CSVWriter;
import seedu.Entities.User;
import seedu.entities.User;

public class UserStorage extends Storage implements FileReadable, FileWritable {
private static final String csvDelimiter = ",";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Definitions/FoodTypes.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Definitions;
package seedu.definitions;

public enum FoodTypes {
INGREDIENT("Ingredient"),
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/Entities/CaloricIntake.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package seedu.Entities;
package seedu.entities;

import java.util.ArrayList;

public class CaloricIntake {
private ArrayList<Meal> DailyCalories;
private ArrayList<Meal> dailyCalories;
private float totalDailyCalories;

public CaloricIntake(ArrayList<Meal> DailyCalories) {
this.DailyCalories = DailyCalories;
public CaloricIntake(ArrayList<Meal> dailyCalories) {
this.dailyCalories = dailyCalories;
calculateTotalCalories();
}

public ArrayList<Meal> getDailyCalories(){
return this.DailyCalories;
return this.dailyCalories;
}

public void setDailyCalories(ArrayList<Meal> DailyCalories) {
this.DailyCalories = DailyCalories;
public void setDailyCalories(ArrayList<Meal> dailyCalories) {
this.dailyCalories = dailyCalories;
}

public float getTotalDailyCalories() {
return this.totalDailyCalories;
}

public void calculateTotalCalories() {
for (Meal meal : DailyCalories ) {
for (Meal meal : dailyCalories) {
this.totalDailyCalories += meal.getTotalCalories();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Entities/Dish.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Entities;
package seedu.entities;

public class Dish extends Food {
public Dish(int id, String name, String storeName, int storeNumber, float calories) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Entities/Food.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Entities;
package seedu.entities;

public abstract class Food {
protected int id;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Entities/Ingredient.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Entities;
package seedu.entities;

public class Ingredient extends Food {
public Ingredient(int id, String name, String storeName, int storeNumber, float calories) {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/seedu/Entities/Meal.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Entities;
package seedu.entities;

import java.util.ArrayList;

Expand Down Expand Up @@ -43,8 +43,7 @@ public String[] toWriteFormat(String delimiter) {
String[] output = new String[2];
output[0] = date;
String[] foodArray = new String[foods.size()];
for (int i = 0; i < foods.size(); i++)
{
for (int i = 0; i < foods.size(); i++) {
foodArray[i] = String.valueOf(foods.get(i).getId());
}
output[1] = String.join(delimiter, foodArray);
Expand All @@ -56,8 +55,7 @@ public String toString() {
String output = "Meal was consumed on " + date + "\n";
output += "Total Calories are: " + this.getTotalCalories() + "\n";
output += "Here are the foods you ate:\n";
for (int i = 0; i < foods.size(); i++)
{
for (int i = 0; i < foods.size(); i++) {
output += (i+1) + ") " + foods.get(i).toString() + "\n";
}
return output;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Entities/Side.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Entities;
package seedu.entities;

public class Side extends Food {
public Side(int id, String name, String storeName, int storeNumber, float calories) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Entities/User.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Entities;
package seedu.entities;
public class User {
private String name;
private float weight;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Exceptions;
package seedu.exceptions;

public class InvalidArgumentsException extends LifeTrackerException {
public InvalidArgumentsException(String commandWord) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Exceptions;
package seedu.exceptions;

public class InvalidCommandException extends LifeTrackerException{

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/Exceptions/LifeTrackerException.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.Exceptions;
package seedu.exceptions;

public class LifeTrackerException extends Exception {
public LifeTrackerException(String errorMessage) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/LifeTracker/LifeTracker.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package seedu.LifeTracker;
package seedu.lifetracker;

import seedu.Commands.Command;
import seedu.Database.FoodStorage;
import seedu.Database.MealStorage;
import seedu.Database.UserStorage;
import seedu.Exceptions.LifeTrackerException;
import seedu.Parser.CommandParser;
import seedu.Ui.GeneralUi;
import seedu.commands.Command;
import seedu.database.FoodStorage;
import seedu.database.MealStorage;
import seedu.database.UserStorage;
import seedu.exceptions.LifeTrackerException;
import seedu.parser.CommandParser;
import seedu.ui.GeneralUi;
import java.nio.file.Paths;

public class LifeTracker {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/Output/UI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.Output;
package seedu.output;

import seedu.Database.FoodStorage;
import seedu.Entities.Food;
import seedu.database.FoodStorage;
import seedu.entities.Food;

import java.util.Scanner;

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/seedu/Parser/CommandParser.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package seedu.Parser;
package seedu.parser;

import seedu.Commands.AddMealCommand;
import seedu.Commands.UpdateUserCommand;
import seedu.Commands.ViewUserCommand;
import seedu.Commands.Command;
import seedu.Commands.DeleteMealCommand;
import seedu.Commands.ExitCommand;
import seedu.Commands.ListCommand;
import seedu.Exceptions.InvalidCommandException;
import seedu.Exceptions.LifeTrackerException;
import seedu.commands.AddMealCommand;
import seedu.commands.UpdateUserCommand;
import seedu.commands.ViewUserCommand;
import seedu.commands.Command;
import seedu.commands.DeleteMealCommand;
import seedu.commands.ExitCommand;
import seedu.commands.ListCommand;
import seedu.exceptions.InvalidCommandException;
import seedu.exceptions.LifeTrackerException;

public class CommandParser {
public static Command parse(String userInput) throws LifeTrackerException {
Expand Down
Loading

0 comments on commit 555023b

Please sign in to comment.