Class FoodItem

java.lang.Object
edu.ntnu.stud.idatt1005.team3.model.FoodItem

public class FoodItem extends Object
Represents a food item with its name and quantity.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FoodItem(String name, double quantity, String unit, int id)
    Constructs a food item with the given name and quantity.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares the food item to another object and check if they are equal.
    int
    Returns the id of the food item.
    Returns the name of the food item.
    Returns the quantity of the food item.
    Returns the unit of the food item.
    int
    Returns the hash code of the food item.
    void
    setQuantity(Double quantity)
    Sets the quantity of the food item.
    Returns a string representation of the food item.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FoodItem

      public FoodItem(String name, double quantity, String unit, int id)
      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

      public String getName()
      Returns the name of the food item.
      Returns:
      Returns the name of the food item.
    • getQuantity

      public Double 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

      public void setQuantity(Double quantity)
      Sets the quantity of the food item.
      Parameters:
      quantity - The quantity of the food item.
    • getUnit

      public String getUnit()
      Returns the unit of the food item.
      Returns:
      Returns the unit of the food item.
    • toString

      public String toString()
      Returns a string representation of the food item.
      Overrides:
      toString in class Object
      Returns:
      Returns a string representation of the food item.
    • equals

      public boolean equals(Object o)
      Compares the food item to another object and check if they are equal.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare to.
      Returns:
      Returns true if the objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code of the food item.
      Overrides:
      hashCode in class Object
      Returns:
      Returns the hash code of the food item.