Class FoodItem
java.lang.Object
edu.ntnu.stud.idatt1005.team3.model.FoodItem
Represents a food item with its name and quantity.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares the food item to another object and check if they are equal.int
getId()
Returns the id of the food item.getName()
Returns the name of the food item.Returns the quantity of the food item.getUnit()
Returns the unit of the food item.int
hashCode()
Returns the hash code of the food item.void
setQuantity
(Double quantity) Sets the quantity of the food item.toString()
Returns a string representation of the food item.
-
Constructor Details
-
FoodItem
Constructs a food item with the given name and quantity.- Parameters:
name
- The name of the food item.quantity
- The quantity of the food item.
-
-
Method Details
-
getName
Returns the name of the food item.- Returns:
- Returns the name of the food item.
-
getQuantity
Returns the quantity of the food item.- Returns:
- Returns the quantity of the food item.
-
getId
public int getId()Returns the id of the food item.- Returns:
- Returns the id of the food item.
-
setQuantity
Sets the quantity of the food item.- Parameters:
quantity
- The quantity of the food item.
-
getUnit
Returns the unit of the food item.- Returns:
- Returns the unit of the food item.
-
toString
Returns a string representation of the food item. -
equals
Compares the food item to another object and check if they are equal. -
hashCode
public int hashCode()Returns the hash code of the food item.
-