Skip to content
Snippets Groups Projects
Commit f0ef08ed authored by HSoreide's avatar HSoreide
Browse files

Add JavaDoc to Income and Expense classes

parent 3fd82a1c
No related branches found
No related tags found
1 merge request!3Hs item class
package no.ntnu.idatt1002.demo.data;
public class Expense extends Item{
private ExpenseCategory category;
/**
* This constructor uses the super constructor to set the fields for 'amount' and 'recurring' and then sets the
* category. A IllegalArgumentException from this constructor if the category is left blank. The description
* field is left to the default blank string.
*
* @param amount The amount of the current Expense object as a double.
* @param recurring True if the current Expense repeats at regular intervals.
* @param category The category to which the Expense belongs to, provided as a value of ExpenseCategory.
*/
public Expense(double amount, boolean recurring, ExpenseCategory category) {
super(amount, recurring);
......@@ -14,6 +21,14 @@ public class Expense extends Item{
this.category = category;
}
/**
* 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 Expense as a String.
* @param amount The amount of the current Expense object as a double.
* @param recurring True if the current income repeats at regular intervals.
* @param category The category to which the Expense belongs to, provided as a value of ExpenseCategory
*/
public Expense(String description, double amount, boolean recurring, ExpenseCategory category) {
super(description, amount, recurring);
if(category == null) {
......@@ -24,20 +39,20 @@ public class Expense extends Item{
}
/**
* The method returns the category to which the Item belongs as a value of the Category enum class.
* @return The category the Item belongs to as a value of the Category enum class.
* The method returns the category to which the Expense belongs as a value of the ExpenseCategory enum class.
* @return The category the Expense belongs to as a value of the ExpenseCategory enum class.
*/
public ExpenseCategory getCategory() {
return category;
}
/**
* The method sets the category of an item to a value of the Category enum class.
* @param expenseCategory The category to which the Item should belong.
* The method sets the category of an expense to a value of the ExpenseCategory enum class.
* @param expenseCategory The category to which the expense belongs as a value of the ExpenseCategory enum.
*/
public void setCategory(ExpenseCategory expenseCategory) {
if(expenseCategory == null) {
throw new IllegalArgumentException("The category must be valid.");
throw new IllegalArgumentException("The income must belong to a category.");
}
this.category = expenseCategory;
}
......
......@@ -4,6 +4,7 @@ public enum ExpenseCategory {
FOOD,
CLOTHES,
BOOKS,
OTHER,
}
package no.ntnu.idatt1002.demo.data;
/**
* The Income class inherits from the Item class. The Item class additionally has a private field for an
* enum value of IncomeCategory.
*
* @author Hanne-Sofie
*/
public class Income extends Item{
private IncomeCategory category;
/**
* This constructor uses the super constructor to set the fields for 'amount' and 'recurring' and then sets the
* category. A IllegalArgumentException from this constructor if the category is left blank. The description
* field is left to the default blank string.
*
* @param amount The amount of the current income object as a double.
* @param recurring True if the current income repeats at regular intervals.
* @param category The category to which the Income belongs to, provided as a value of IncomeCategory.
*/
public Income(double amount, boolean recurring, IncomeCategory category) {
super(amount, recurring);
......@@ -13,6 +28,14 @@ public class Income extends Item{
this.category = category;
}
/**
* 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.
* @param category The category to which the income belongs to, provided as a value of IncomeCategory
*/
public Income(String description, double amount, boolean recurring, IncomeCategory category) {
super(description, amount, recurring);
if(category == null) {
......@@ -23,8 +46,8 @@ public class Income extends Item{
}
/**
* The method returns the category to which the Item belongs as a value of the Category enum class.
* @return The category the Item belongs to as a value of the Category enum class.
* The method returns the category to which the Income belongs as a value of the IncomeCategory enum.
* @return The category to which the Income belongs to as a value of the IncomeCategory enum.
*/
public IncomeCategory getCategory() {
return category;
......@@ -32,7 +55,7 @@ public class Income extends Item{
/**
* The method sets the category of an item to a value of the Category enum class.
* @param category The category to which the Item should belong.
* @param category The category to which the Income belongs to as a value of the IncomeCategory enum.
*/
public void setCategory(IncomeCategory category) {
if(category == null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment