public class Product
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Product.Unit
Enum representing all the possible units that may be used for a product.
|
Modifier and Type | Field and Description |
---|---|
private double |
carbohydrateGramsPerUnit |
private double |
lipidGramsPerUnit |
private static int |
MIN_VALUE_ACCEPTED |
private java.lang.String |
name |
private double |
proteinsGramsPerUnit |
private static int |
TO_KILO_MULTIPLIER |
private Product.Unit |
unit |
Constructor and Description |
---|
Product(Product product)
Copy constructor.
|
Product(java.lang.String name,
Product.Unit unit,
double lipids,
double proteins,
double carbohydrates)
Product constructor.
|
Modifier and Type | Method and Description |
---|---|
static double |
computeMacroAmountPer100g(double amountOfProduct,
double macroAmountPerUnit)
Compute the exact quantity of a nutritional value(lipids or proteins or carbohydrates).
|
static double |
computeNumberOfCalories(double proteins,
double lipids,
double carbohydrates)
Compute the exact quantity of calories of a product
by multiplying each parameter with a specific constant of the parameter and then we sum all of the values
to obtain the exact quantity of calories of a product.
|
boolean |
equals(java.lang.Object o) |
double |
getCarbohydrateGramsPerUnit() |
double |
getLipidGramsPerUnit() |
java.lang.String |
getName() |
double |
getProteinGramsPerUnit() |
Product.Unit |
getUnit() |
java.lang.String |
getUnitName() |
int |
hashCode() |
java.lang.String |
toString() |
private static final int TO_KILO_MULTIPLIER
private static final int MIN_VALUE_ACCEPTED
private final double lipidGramsPerUnit
private final double proteinsGramsPerUnit
private final double carbohydrateGramsPerUnit
private java.lang.String name
private Product.Unit unit
public Product(java.lang.String name, Product.Unit unit, double lipids, double proteins, double carbohydrates)
name,
- the name of the productunit,
- the unit of the product (either Kg, L or Unit)lipids,
- lipids per 100g (for Kg and L) or per unit (for Unit)proteins,
- proteins per 100g (for Kg and L) or per unit (for Unit)carbohydrates,
- proteins per 100g (for Kg and L) or per unit (for Unit)public Product(Product product)
product
- public static double computeMacroAmountPer100g(double amountOfProduct, double macroAmountPerUnit)
amountOfProduct
- quantity of the productmacroAmountPerUnit
- the basic quantity of a nutritional value.public static double computeNumberOfCalories(double proteins, double lipids, double carbohydrates)
proteins
- value in grams of proteinslipids
- value in grams of lipidscarbohydrates
- value in grams of carbohydratespublic Product.Unit getUnit()
public java.lang.String getName()
public java.lang.String getUnitName()
public java.lang.String toString()
toString
in class java.lang.Object
public double getLipidGramsPerUnit()
public double getProteinGramsPerUnit()
public double getCarbohydrateGramsPerUnit()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object