From 6a91434602a86932e7f04117d0b849e89bdf3977 Mon Sep 17 00:00:00 2001 From: Harry Linrui XU <xulr0820@hotmail.com> Date: Sun, 23 Apr 2023 14:00:07 +0200 Subject: [PATCH] Added javadoc to all methods and class names that triggered an error from running mvn javadoc:javadoc --- .../demo/controller/AddBudgetController.java | 13 + .../demo/controller/AddExpenseController.java | 19 ++ .../demo/controller/AddIncomeController.java | 28 +- .../demo/controller/AllRecipesController.java | 2 +- .../controller/CreateBudgetController.java | 7 + .../controller/IngredientTileController.java | 2 +- .../controller/SelectBudgetController.java | 3 +- .../demo/data/Budget/BudgetItem.java | 40 ++- .../demo/data/Budget/BudgetRegister.java | 8 +- .../Budget/FileHandlingBudgetArchive.java | 4 +- .../Budget/FileHandlingSelectedBudget.java | 4 + .../demo/data/Budget/GeneralBudget.java | 9 +- .../ntnu/idatt1002/demo/data/Budget/MMBI.java | 34 +++ .../idatt1002/demo/data/Budget/Savings.java | 2 +- .../demo/data/Economics/Expense.java | 16 +- .../demo/data/Economics/ExpenseCategory.java | 45 ++- .../demo/data/Economics/FileHandling.java | 2 + .../idatt1002/demo/data/Economics/Income.java | 6 + .../demo/data/Economics/IncomeCategory.java | 29 ++ .../idatt1002/demo/data/Economics/Item.java | 46 ++- .../demo/data/recipes/FileHandler.java | 1 + .../idatt1002/demo/data/recipes/FoodItem.java | 261 +++++++++++++++++- .../demo/data/recipes/MeasuringUnit.java | 48 ++++ .../java/no/ntnu/idatt1002/demo/view/App.java | 12 + .../no/ntnu/idatt1002/demo/view/MyApp.java | 16 +- 25 files changed, 629 insertions(+), 28 deletions(-) diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/AddBudgetController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/AddBudgetController.java index de9c4872..e7eb2aae 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/AddBudgetController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/AddBudgetController.java @@ -66,10 +66,20 @@ public class AddBudgetController { addEventFilters(); } + /** + * Gets the category value from the category combo box. + + * @return The category value + */ public ExpenseCategory getCategory(){ return categoryVariable.getValue(); } + /** + * Gets the newly created budget item + + * @return The budget item + */ public BudgetItem getNewBudgetItem(){ return this.newBudgetItem; } @@ -78,6 +88,7 @@ public class AddBudgetController { * Binds the item that is taken in as the argument with a budget item declared in this class. The item of this class is instantiated * as a deep copy of the argument. Each attribute of their attributes are then bounded. The text fields and category boxes * in the dialog window are then set to the values of the chosen item, as to not display empty values. + * @param item The item that is chosen to be edited. */ @FXML @@ -98,6 +109,7 @@ public class AddBudgetController { * Adds a new to the budget tableview or edits an existing entry in table if the OK button is pressed. * An entry is edited as the selected entry of the table is bounded to another budget item in this class. If this budget item * is altered, the budget item in the tableview will automatically respond with the same changes. + * @param event If the OK button is pressed. */ @FXML @@ -158,6 +170,7 @@ public class AddBudgetController { /** * Closes the dialog box. + * @param actionEvent A button click on the close button. */ @FXML diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/AddExpenseController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/AddExpenseController.java index e24143df..42ec029c 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/AddExpenseController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/AddExpenseController.java @@ -24,6 +24,7 @@ import no.ntnu.idatt1002.demo.data.Economics.Expense; /** * Class that represents the popup dialog box that appears whenever an expense is to be added or edited. * The dialog contains various fields that are used to create a new expense or edit an existing expense. + * * @author Harry Linrui Xu * @since 13.3.2023 */ @@ -86,14 +87,29 @@ public class AddExpenseController { addEventFilters(); } + /** + * Gets the value of the category box. + + * @return The chosen expense category. + */ public ExpenseCategory getCategory() { return categoryBox.getValue(); } + /** + * Gets the value from the recurring box. + + * @return The chosen recurring boolean value. + */ public boolean isRecurring() { return recurringBox.getValue();//.equals("Yes"); } + /** + * Gets the newly created expense + + * @return The new expense. + */ public Expense getNewExpense() { return this.newExpense; } @@ -102,6 +118,7 @@ public class AddExpenseController { * Binds the expense that is taken in as the argument with an expense declared in this class. The expense of this class is instantiated * as a deep copy of the argument. Each attribute of their attributes are then bounded. The text fields and category boxes * in the dialog window are then set to the values of the chosen expense, as to not display empty values. + * @param expense The expense that is chosen to be edited. */ public void setExpense(Expense expense) { @@ -125,6 +142,7 @@ public class AddExpenseController { * Adds a new to the tableview or edits an existing entry in table if the OK button is pressed. * An entry is edited as the selected entry of the table is bounded to another expense in this class. If this expense * is altered, the expense in the tableview will automatically respond with the same changes. + * @param event If the OK button is pressed. */ @FXML @@ -153,6 +171,7 @@ public class AddExpenseController { /** * Closes the dialog box and cancels any pending changes. + * @param event A button click on the cancel button. */ @FXML diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/AddIncomeController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/AddIncomeController.java index 6f2d26d3..c3981ba8 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/AddIncomeController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/AddIncomeController.java @@ -23,6 +23,7 @@ import no.ntnu.idatt1002.demo.data.Economics.IncomeCategory; /** * Class that represents the popup dialog box that appears whenever an income is to be added or edited. * The dialog contains various fields that are used to create a new income or edit an existing income. + * * @author Harry Linrui Xu * @since 24.3.2023 */ @@ -80,14 +81,29 @@ public class AddIncomeController { addEventFilters(); } + /** + * Gets the value of the category box. + + * @return The chosen income category. + */ public IncomeCategory getCategory() { return categoryBox.getValue(); } + /** + * Gets the value from the recurring box. + + * @return The chosen recurring boolean value. + */ public boolean isRecurring() { return recurringBox.getValue();//.equals("Yes"); } + /** + * Gets the newly created income + + * @return The new income. + */ public Income getNewIncome() { return this.newIncome; } @@ -96,11 +112,13 @@ public class AddIncomeController { * Binds the income that is taken in as the argument with an income declared in this class. The income of this class is instantiated * as a deep copy of the argument. Each attribute of their attributes are then bounded. The text fields and category boxes * in the dialog window are then set to the values of the chosen income, as to not display empty values. + * @param income The income that is chosen to be edited. */ public void setIncome(Income income) { //Deep copying income and then binding the two incomes - chosenIncome = new Income(income.getDescription(), income.getAmount(), income.isRecurring(), income.getCategory(), income.getDate()); + chosenIncome = new Income(income.getDescription(), income.getAmount(), income.isRecurring(), + income.getCategory(), income.getDate()); chosenIncome.descriptionProperty().bindBidirectional(income.descriptionProperty()); chosenIncome.amountProperty().bindBidirectional(income.amountProperty()); chosenIncome.recurringProperty().bindBidirectional(income.recurringProperty()); @@ -118,8 +136,9 @@ public class AddIncomeController { /** * Adds a new to the tableview or edits an existing entry in table if the OK button is pressed. - * An entry is edited as the selected entry of the table is bounded to another income in this class. If this income - * is altered, the income in the tableview will automatically respond with the same changes. + * An entry is edited as the selected entry of the table is bounded to another income in this class. + * If this income is altered, the income in the tableview will automatically respond with the same changes. + * @param event If the OK button is pressed. */ @FXML @@ -133,7 +152,8 @@ public class AddIncomeController { boolean recurring = isRecurring(); newIncome = new Income(description, amount, recurring, category, date); } - //Sets the value of the income(chosenIncome) that is bounded to the chosen income (not chosenIncome) in the tableview + //Sets the value of the income(chosenIncome) that is bounded to the + // chosen income (not chosenIncome) in the tableview if (chosenIncome != null) { chosenIncome.setDescription((descriptionField.getText())); chosenIncome.setAmount(Double.parseDouble(amountField.getText())); diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/AllRecipesController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/AllRecipesController.java index 80de931b..3c0897f4 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/AllRecipesController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/AllRecipesController.java @@ -48,7 +48,7 @@ public class AllRecipesController implements Initializable { * initialize the controller once its root element has been processed. The method then reads and creates * an object of the IngredientsAtHand class and one of the RecipesRegister class. * If the recipe register exists, the list is filled with Strings for each recipe at the format: - * <Recipe name> - X missing ingredients (XX%) + * Recipe name - X missing ingredients (XX%) * Finally, a MouseClick event and handler is attached to the list that gets the recipe name of the clicked * list item and runs the method showRecipe() with that name as input to show the recipe in detail in the * view Recipe.fxml. diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/CreateBudgetController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/CreateBudgetController.java index c3e28623..405bfab1 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/CreateBudgetController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/CreateBudgetController.java @@ -28,8 +28,15 @@ public class CreateBudgetController { private String budgetName; + /** + * The ok button in the dialog window. + */ @FXML public Button okBtn; + + /** + * The cancel button in the dialog window. + */ @FXML public Button cancelBtn; diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/IngredientTileController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/IngredientTileController.java index 3762ad3c..ea8957f4 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/IngredientTileController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/IngredientTileController.java @@ -20,7 +20,7 @@ public class IngredientTileController { /** * The setData method takes an RecipeIngredient object as parameter and sets the text of the label contained in * the simple pane to a formatted string following this pattern: - * "# <Ingredient name> XX.X YY" + * "# Ingredient name XX.X YY" * where XX.X is the amount of the ingredient in the recipe and YY is the unit of measure. * @param ingredient An RecipeIngredient object to format and create an Ingredient tile for. */ diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/SelectBudgetController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/SelectBudgetController.java index 4c59fc1e..9bd6b1ff 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/SelectBudgetController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/SelectBudgetController.java @@ -42,10 +42,9 @@ public class SelectBudgetController { /** * Initializes the view when it is loaded. Prepares the view by adding event filters, * instantiating the budget register and setting the list view. - * @throws IOException */ @FXML - public void initialize() throws IOException { + public void initialize() { //Prevent users from choosing nothing okBtn.addEventFilter( ActionEvent.ACTION, event -> { diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetItem.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetItem.java index db057a1a..47518a43 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetItem.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetItem.java @@ -37,14 +37,23 @@ public class BudgetItem { * This method gets the BudgetAmount. * * @return the budgetAmount as a double - * */ public double getBudgetAmount() { return budgetAmount.get(); } - public DoubleProperty getAmountProperty(){ return budgetAmount;} + /** + * Gets the amount property of its corresponding amount value. + + * @return The amount property. + */ + public DoubleProperty getAmountProperty(){ return budgetAmount;} + + /** + * Sets the amount to the value of the argument. + * @param amount The value to which the amount will change. + */ public void setBudgetAmount(double amount){ this.budgetAmount.set(amount); } @@ -53,13 +62,23 @@ public class BudgetItem { * This method gets the category. * * @return the category as one of the categories in ExpenseCategory - * */ public ExpenseCategory getBudgetCategory() { return budgetCategory.get(); } + + /** + * Gets the category property of its corresponding category value. + + * @return The category property. + */ public ObjectProperty<ExpenseCategory> getCategoryProperty(){ return budgetCategory; } + /** + * Sets the budget category to the value of the argument. + + * @param category Category to which the budget item will change. + */ public void setBudgetCategory(ExpenseCategory category){ this.budgetCategory.set(category); } @@ -67,18 +86,29 @@ public class BudgetItem { /** * This method gets the description. * - * @return the description as a String - * + * @return the description as a String. */ public String getBudgetDescription() { return budgetDescription.get(); } + + /** + * Gets the description property of its corresponding description value. + + * @return The description property. + */ public StringProperty getDescriptionProperty(){ return budgetDescription; } + /** + * Sets the budget description to the value of the argument. + + * @param description Description to which the budget description will change. + */ public void setBudgetDescription(String description){ this.budgetDescription.set(description); } + @Override public String toString() { return "budgetAmount=" + getBudgetAmount() + diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetRegister.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetRegister.java index 7f9270a9..3e019541 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetRegister.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/BudgetRegister.java @@ -21,8 +21,14 @@ public class BudgetRegister { budgetNames = new ArrayList<>(); } + /** + * Gets a list of the budget names contained in the budget register. + + * @return Deep copied list of budget names. + */ public List<String> getBudgetNames() { - return this.budgetNames; + List<String> budgetNamesCopy = new ArrayList<>(budgetNames); + return budgetNamesCopy; } /** diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java index 5b559c56..3599d709 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java @@ -48,6 +48,7 @@ public class FileHandlingBudgetArchive { * Method for writing (adding) a budget register to the archive. * @param budgetNames The budget register. + * @param fileTitle The title of the file. * @throws IOException if an input or output exception occurred. */ public static void writeBudgetRegisterToArchive(BudgetRegister budgetNames, @@ -64,6 +65,7 @@ public class FileHandlingBudgetArchive { * Checks if the budget register in the archive contains any budget names. * In other words, if it is empty. + * @param fileTitle title of the file. * @return True, if only "null" is read. Else, returns false. * @throws IOException if an input or output exception occurred. */ @@ -110,7 +112,7 @@ public class FileHandlingBudgetArchive { * that should be removed should have their directory deleted. * @param budgetId The name of the budget directory that holds all the data - * for a given budget. + * for a given budget. * @return True, if the directory is successfully deleted. Else, returns false. */ public static boolean deleteBudgetDirectory(String budgetId) { diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java index 20b1ea92..9a0b065c 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java @@ -25,6 +25,7 @@ public class FileHandlingSelectedBudget { /** * Reads the name of the currently selected budget. + * @param fileTitle The title of the file. * @return A string of the budget name. * @throws IOException if an input or output exception occurred. */ @@ -42,7 +43,9 @@ public class FileHandlingSelectedBudget { /** * Writes the currently used budget name to file, essentially updating the * file. + * @param budgetName The name of the budget. + * @param fileTitle Title of the file. * @throws IOException if an input or output exception occurred. */ public static void updateSelectedBudget(String budgetName, String fileTitle) throws IOException { @@ -61,6 +64,7 @@ public class FileHandlingSelectedBudget { * Clears the entire file that holds the current budget. In case a budget is deleted, * this method prevents the file of containing a budget name that no longer exists. + * @param fileTitle The title of the file. * @throws IOException if an input or output exception occurred. */ public static void clearSelectedBudget(String fileTitle) throws IOException { diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/GeneralBudget.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/GeneralBudget.java index ba766c72..d7f1577a 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/GeneralBudget.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/GeneralBudget.java @@ -34,7 +34,14 @@ public class GeneralBudget { */ private final Savings savings; + /** + * Constructor for a general budget, which is an entire budget project, set + * for a given month. + * @param budgetItems List of the budget items in the project. + * @param maxAmount Money at disposable to allocate. + * @param savings Unused money from last month. + */ public GeneralBudget(List<BudgetItem> budgetItems, double maxAmount, Savings savings) { if (maxAmount < 0) { throw new IllegalArgumentException("The max amount of the budget cant be less than zero"); @@ -101,7 +108,7 @@ public class GeneralBudget { * Method for getting budgetItems * * @return an ArrayList of every BudgetItem - * @throws if budgetItems is empty + * @throws IllegalArgumentException if budgetItems is empty */ public List<BudgetItem> getBudgetItems() throws IllegalArgumentException { return budgetItems; diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java index 291d1651..fe15c583 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/MMBI.java @@ -2,27 +2,61 @@ package no.ntnu.idatt1002.demo.data.Budget; import javafx.scene.control.ProgressBar; +/** + * Class that represents the main menu category progress bars. Each bar + * is associated with a corresponding expense category. + * + * @author Anders Emil Bergan. + * @since 17.04.2023. + */ public class MMBI { private ProgressBar progressBar; private BudgetItem budgetItem; + /** + * Constructor for creating a MMBI. + + * @param item The budget item. + * @param bar The progress bar. + */ public MMBI(BudgetItem item, ProgressBar bar){ this.budgetItem = item; this.progressBar = bar; } + /** + * Gets the budget item. + + * @return the budget item. + */ public BudgetItem getBudgetItem(){ return budgetItem; } + /** + * Sets the budget item to the argument value. + + * @param item The value to which the budget item will be set. + */ public void setBudgetItem(BudgetItem item){ this.budgetItem = item; } + + /** + * Gets the progress bar. + + * @return the progress bar. + */ public ProgressBar getBar(){ return progressBar; } + /** + * Sets the progress bar to the argument value. + + * @param bar The value to which the progress bar will be set. + */ public void setProgressBar(ProgressBar bar){ this.progressBar = bar; } diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/Savings.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/Savings.java index 2bd4d476..a16a25a5 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/Savings.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/Savings.java @@ -58,7 +58,7 @@ public class Savings { * amount to a given double. * * @param savingsGoals the ArrayList you want to assign savingsGoals - * @param amount + * @param amount The amount of the saving. */ public Savings(ArrayList<SavingsGoal> savingsGoals, double amount) { this.savingsGoals = savingsGoals; diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java index de47509b..a1253e1d 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Expense.java @@ -6,8 +6,17 @@ import javafx.beans.property.SimpleObjectProperty; import java.time.LocalDate; import java.util.Objects; +/** + * This class represents an expense. An expense is an object consisting of four mandatory + * parameters being its amount, whether it is recurring, a category, a date it was created + * and the optional description. Expense inherits from the abstract Item class where the + * category parameter is unique. + * + * @author Hanne-Sofie Søreide + * @since 05.03.2023 + */ public class Expense extends Item{ - private ObjectProperty<ExpenseCategory> category; + private final ObjectProperty<ExpenseCategory> category; /** * This constructor uses the super constructor to set the fields for 'amount' and 'recurring' and then sets the @@ -45,6 +54,11 @@ public class Expense extends Item{ this.category = new SimpleObjectProperty<>(category); } + /** + * Gets an Object Property of the Expense Category. + + * @return Expense Category property. + */ public ObjectProperty<ExpenseCategory> expenseCategoryObjectProperty() { return this.category; } diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java index 4a94a256..54b445d1 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/ExpenseCategory.java @@ -1,18 +1,61 @@ package no.ntnu.idatt1002.demo.data.Economics; +/** + * This class represents various types of expenditures that a user can choose from. + * While not covering every kind of expense they give a good range to work with. + * + * @author Andreas Kluge Svensrud. + * @since 02.03.2023. + */ public enum ExpenseCategory { + /** + * Expenditures on food, such as groceries. + */ FOOD("food"), + + /** + * Expenditures on rent. + */ RENT("rent"), + + /** + * Expenditures on clothes. + */ CLOTHES("clothes"), + + /** + * Expenditures on books. + */ BOOKS("books"), + + /** + * Expenditures on health. + */ HEALTH("health"), + + /** + * Expenditures on activities, such as a bowling night. + */ ACTIVITIES("activities"), - OTHER("other"); + /** + * Expenditures on everything not listed above. + */ + OTHER("other"); + /** + * Label of the categories. The label formats + * the string value of the categories two string in lower caps. + */ public final String label; + /** + * The constructor of the enum constants takes in a string label and assigns + * it to its respective constant. + * The label is used for representation in texts and lists at the frontend of the application. + * @param label A lower-case and readable string representation of the enum constant. + */ ExpenseCategory(String label) { this.label = label; } diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/FileHandling.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/FileHandling.java index 6051903b..78391f84 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/FileHandling.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/FileHandling.java @@ -25,10 +25,12 @@ public class FileHandling{ /** * Method for writing (adding) an ItemRegister to a file. * + * @param <T> Subclass of item, either expense or income. * @param itemRegister the ItemRegister you want to write to a file. * @param fileTitle the name of the file you want to check * @throws IOException if an input or output exception occurred. */ + public static <T extends Item>void writeItemRegisterToFile(final ItemRegister<T> itemRegister, String fileTitle) throws IOException { try (BufferedWriter bw = new BufferedWriter(new FileWriter(filePath + fileTitle + fileType))) { if (itemRegister.isEmpty()){ diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java index 4b8eaae9..6eaf54f9 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Income.java @@ -38,6 +38,7 @@ public class Income extends Item{ /** * This constructor uses the super constructor to set the fields for 'amount', 'description' and 'recurring' * and then sets the category. A IllegalArgumentException from this constructor if the category is left blank. + * @param description A description of the income as a String. * @param amount The amount of the current income object as a double. * @param recurring True if the current income repeats at regular intervals. @@ -53,6 +54,11 @@ public class Income extends Item{ } + /** + * Gets the ObjectProperty of the category value. + + * @return The property of the income category. + */ public ObjectProperty<IncomeCategory> incomeCategoryObjectProperty() { return this.category; } diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java index 5c5ce82c..7338c360 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/IncomeCategory.java @@ -1,12 +1,41 @@ package no.ntnu.idatt1002.demo.data.Economics; +/** + * This class represents various types of income that a user can choose from. + * While not covering every kind of income they give a good range to work with. + * + * @author HanneSofie + * @since 05.03.2023. + */ public enum IncomeCategory { + + /** + * The monthly salary of the user. + */ SALARY("salary"), + + /** + * The monthly amount the user receives in student loan. + */ STUDENT_LOAN("student loan"), + + /** + * Monetary gifts. + */ GIFT("gift"); + /** + * Label of the categories. The label formats + * the string value of the categories two string in lower caps. + */ public final String label; + /** + * The constructor of the enum constants takes in a string label and assigns it to + * its respective constant. + * The label is used for representation in texts and lists at the frontend of the application. + * @param label A lower-case and readable string representation of the enum constant. + */ IncomeCategory(String label) { this.label = label; } diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java index 57c2a8f7..b6737f74 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Economics/Item.java @@ -7,21 +7,41 @@ import javafx.beans.property.*; /** * The Item class represents a good or service purchased in real life. The item belongs to a category and - * has an amount, description and a date. The description may be left blank, but the Item must belong to a category and must - * have a price. - * @author HanneSofie + * has an amount, description and a date. The description may be left blank, + * but the Item must belong to a category and must have a price. * + * @author HanneSofie + * @since 02.03.2023 */ public abstract class Item { + + /** + * String property for description. Allows for binding. + */ private StringProperty description = new SimpleStringProperty(""); + + /** + * Double property for amount. Allows for binding. + */ private final DoubleProperty amount; - private BooleanProperty recurring; - private ObjectProperty<LocalDate> date; // Format example: 09.08.23 + + /** + * Boolean property for recurring. Allows for binding. + */ + private final BooleanProperty recurring; + + /** + * ObjectProperty property for date. Allows for binding. + */ + private final ObjectProperty<LocalDate> date; // Format example: 09.08.23 /** * The constructor of a new Item object takes in an amount as a double. If the amount is left blank, an * IllegalArgumentException is thrown. + * @param amount price of an Item as a float. + * @param recurring Value informing if the item is recurring or not. + * @param date The date the item is created. */ public Item (double amount, boolean recurring, LocalDate date){ if(amount <= 1.0f || date.toString().isBlank()) { @@ -37,17 +57,26 @@ public abstract class Item { * The constructor instantiates a new Item object with a category, a description and a price as arguments. It * overloads the first constructor to set the category and price and then sets the description of the item. * If either 0category or price is left blank, an IllegalArgumentException is thrown. + * @param description A description of the item as a String. * @param amount The price of the item as a float. + * @param recurring Value informing if the item is recurring or not. + * @param date The date the item is created.* */ public Item (String description, double amount, boolean recurring, LocalDate date){ this(amount, recurring, date); this.description = new SimpleStringProperty(description); } + /** + * Gets the String Property of the description. + + * @return String property of description. + */ public StringProperty descriptionProperty() { return this.description; } + /** * The method returns the description of the given Item object as a String. * @return The description of the Item as a String. @@ -65,6 +94,11 @@ public abstract class Item { this.description.set(description); } + /** + * Gets the Double Property of the amount. + + * @return Double Property of amount. + */ public DoubleProperty amountProperty() { return this.amount; } @@ -114,7 +148,7 @@ public abstract class Item { /** * The method returns the ObjectProperty of date. - * @return + * @return The date property. */ public ObjectProperty<LocalDate> dateProperty() { return this.date; diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FileHandler.java b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FileHandler.java index 88f42518..958aec76 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FileHandler.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FileHandler.java @@ -172,6 +172,7 @@ public class FileHandler { * @param ingredientsAtHand An IngredientsAtHand object that holds a collection of constants of the * FoodItem enum class. * @param title The title by which to name the file that the ingredients at hand are written to. + * @throws IOException if an input or output error occurs. */ public static void writeIngredientsAtHand(IngredientsAtHand ingredientsAtHand, String title) throws IOException { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FoodItem.java b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FoodItem.java index 8dfa3710..30dc12b3 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FoodItem.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/FoodItem.java @@ -7,77 +7,334 @@ package no.ntnu.idatt1002.demo.data.recipes; * to represent each enum value. * * @author hannesofie + * @since 13.03.2023 */ public enum FoodItem { + /** + * Onion + */ ONION("onion"), + + /** + * Minced meat. + */ MINCED_MEAT("minced meat"), + + /** + * Potato. + */ POTATO("potato"), + + /** + * Yellow cheese. + */ YELLOW_CHEESE("yellow cheese"), + + /** + * Wheat flour. + */ WHEAT_FLOUR("wheat flour"), + + /** + * Milk. + */ MILK("milk"), + + /** + * Tomato. + */ TOMATO("tomato"), + + /** + * Orange. + */ ORANGE("orange"), + + /** + * Lemon. + */ LEMON("lemon"), + + /** + * Salsa sauce. + */ SALSA_SAUCE("salsa sauce"), + + /** + * Cucumber. + */ CUCUMBER("cucumber"), + + /** + * Salad. + */ SALAD("salad"), + + /** + * Spinach. + */ SPINACH("spinach"), + + /** + * Spring roll. + */ SPRING_ROLL("spring roll"), + + /** + * Bell pepper. + */ BELL_PEPPER("bell pepper"), + + /** + * Chickpeas. + */ CHICKPEAS("chickpeas"), + + /** + * Spaghetti. + */ SPAGHETTI("spaghetti"), + + /** + * Pasta. + */ PASTA("pasta"), + + /** + * Cream. + */ CREAM("cream"), + + /** + * Honey. + */ HONEY("honey"), + + /** + * Vinegar. + */ VINEGAR("vinegar"), + + /** + * Tomato paste. + */ TOMATO_PASTE("tomato paste"), + + /** + * Chili. + */ CHILLI("chilli"), + + /** + * Egg. + */ EGG("egg"), + + /** + * Olive oil. + */ OLIVE_OIL("olive oil"), + + /** + * Ham. + */ HAM("ham"), + + /** + * Parmesan. + */ PARMESAN("parmesan"), + + /** + * Snap pea. + */ SNAP_PEA("snap pea"), + + /** + * Macaroni. + */ MACARONI("macaroni"), + + /** + * Salmon. + */ SALMON("salmon"), + + /** + * Fish. + */ FISH("fish"), + + /** + * Carrot. + */ CARROT("carrot"), + + /** + * Butter. + */ BUTTER("butter"), + + /** + * Leek. + */ LEEK("leek"), + + /** + * Bread crumbs. + */ BREADCRUMBS("breadcrumbs"), + + /** + * Oil. + */ OIL("oil"), + + /** + * Summer cutlet. + */ SUMMER_CUTLET("summer cutlet"), + + /** + * Red onion. + */ RED_ONION("red onion"), + + /** + * Avocado. + */ AVOCADO("avocado"), + + /** + * Lemon juice. + */ LEMON_JUICE("lemon juice"), + + /** + * Dry thyme. + */ DRY_THYME("dry thyme"), + + /** + * Fresh yeast. + */ FRESH_YEAST("fresh yeast"), + + /** + * Garlic clove. + */ GARLIC_CLOVE("garlic clove"), + + /** + * Ginger. + */ GINGER("ginger"), + + /** + * Canned tomato. + */ CANNED_TOMATO("canned tomato"), + + /** + * Dry basil. + */ DRY_BASIL("dry basil"), + + /** + * Fresh basil. + */ FRESH_BASIL("fresh basil"), + + /** + * Celery. + */ CELERY("celery"), + + /** + * Broth. + */ BROTH("broth"), + + /** + * Bay leaf. + */ BAY_LEAF("bay leaf"), + + /** + * Chili beans. + */ CHILLI_BEANS("chilli beans"), + + /** + * Chili powder. + */ CHILLI_POWDER("chilli powder"), + + /** + * Cumin powder. + */ CUMIN_POWDER("cumin powder"), + + /** + * Pie dough. + */ PIE_DOUGH("pie dough"), + + /** + * Broccoli. + */ BROCCOLI("broccoli"), - LAM("lam"), + + /** + * Lamb + */ + LAMB("lamb"), + + /** + * Sugar. + */ SUGAR("sugar"), + + /** + * Shallot. + */ SHALLOT("shallot"), + + /** + * Red wine. + */ RED_WINE("red wine"), + + /** + * White bananas. + */ WHITE_BEANS("white beans"), + + /** + * Frozen green peas + */ FROZEN_GREEN_PEAS("frozen green peas"), + + /** + * Sausage. + */ SAUSAGE("sausage"), + + /** + * Dry oregano + */ DRY_OREGANO("dry oregano"); + /** + * Label of the categories. The label formats + * the string value of the categories two string in lower caps. + */ public final String label; /** - * The constructor of the enum constants takes in a string label and assigns it to its respective constant. + * The constructor of the enum constants takes in a string label and + * assigns it to its respective constant. * The label is used for representation in texts and lists at the frontend of the application. * @param label A lower-case and readable string representation of the enum constant. */ diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/MeasuringUnit.java b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/MeasuringUnit.java index 5f0165ad..d1d53182 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/recipes/MeasuringUnit.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/recipes/MeasuringUnit.java @@ -6,22 +6,70 @@ package no.ntnu.idatt1002.demo.data.recipes; * presentation to the user. * * @author hannesofie + * @since 13.03.2023 */ public enum MeasuringUnit { + /** + * Deciliter. + */ DL("dl."), + + /** + * Liter. + */ L("l."), + + /** + * Teaspoon. + */ TSP("tsp."), + + /** + * Tablespoon. + */ TBS("tbs."), + + /** + * Gram. + */ GR("gr."), + + /** + * Kilogram + */ KG("kg."), + + /** + * Pieces. + */ PC("pieces"), + + /** + * Can. + */ CAN("can"), + + /** + * Slice + */ SLICE("slice"), + + /** + * Pack + */ PKG("pack"), + + /** + * Cubes. + */ CB("cubes"); + /** + * Label of the categories. The label formats + * the string value of the categories two string in lower caps. + */ public final String label; /** diff --git a/src/main/java/no/ntnu/idatt1002/demo/view/App.java b/src/main/java/no/ntnu/idatt1002/demo/view/App.java index 91586aac..bf128295 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/view/App.java +++ b/src/main/java/no/ntnu/idatt1002/demo/view/App.java @@ -1,6 +1,18 @@ package no.ntnu.idatt1002.demo.view; +/** + * The class from which the main application is caleld upon. + * + * @author Harry Linrui Xu + * @since 11.03.2023 + */ public class App { + + /** + * The main method that calls on the MyApp class + + * @param args String of arguments + */ public static void main(String[] args) { MyApp.main(args); } diff --git a/src/main/java/no/ntnu/idatt1002/demo/view/MyApp.java b/src/main/java/no/ntnu/idatt1002/demo/view/MyApp.java index 148b8852..c274fd98 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/view/MyApp.java +++ b/src/main/java/no/ntnu/idatt1002/demo/view/MyApp.java @@ -8,8 +8,18 @@ import javafx.scene.Scene; import java.io.IOException; +/** + * This is the class that the main application is run from. When a user decides to + * run the application, this class calls on the start method which starts the application. + */ public class MyApp extends Application { + /** + * The start method which is where the application is opened. + + * @param stage The stage or window at which the GUI is displayed. + * @throws IOException If an occurs loading the first view. + */ @Override public void start(Stage stage) throws IOException { FXMLLoader loader = new FXMLLoader(getClass().getResource("/view/FirstMenu.fxml")); @@ -19,7 +29,11 @@ public class MyApp extends Application { stage.show(); } - public static void main(String[] args) { + /** + * The main method that calls on the start method. + * @param args String of arguments. + */ + public static void main(String[] args) { launch(args); } } -- GitLab