68 lines
1.3 KiB
Java
68 lines
1.3 KiB
Java
public class FridgeItem implements Weightful {
|
|
|
|
/**
|
|
* The weight of the item.
|
|
*/
|
|
private double weight;
|
|
|
|
/**
|
|
* The name of the item.
|
|
*/
|
|
private String name;
|
|
|
|
/**
|
|
* The color of the item.
|
|
*/
|
|
private String color;
|
|
|
|
/**
|
|
* Creates a fridge item with the specified weight, name and color.
|
|
*
|
|
* @param weight The weight of the item.
|
|
* @param name The name of the item.
|
|
* @param color The color of the item.
|
|
*/
|
|
public FridgeItem(double weight, String name, String color) {
|
|
this.weight = weight;
|
|
this.name = name;
|
|
this.color = color;
|
|
}
|
|
|
|
/**
|
|
* Returns the name of the item.
|
|
*
|
|
* @return The name of the item.
|
|
*/
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
/**
|
|
* Returns the color of the item.
|
|
*
|
|
* @return The color of the item.
|
|
*/
|
|
public String getColor() {
|
|
return color;
|
|
}
|
|
|
|
/**
|
|
* Returns the weight of the item.
|
|
*
|
|
* @return The weight of the item.
|
|
*/
|
|
public double getWeight() {
|
|
return weight;
|
|
}
|
|
|
|
/**
|
|
* Returns a string representation of the item.
|
|
*
|
|
* @return A string representation of the item.
|
|
*/
|
|
public String toString() {
|
|
return name + " (" + color + " " + weight + " g)";
|
|
}
|
|
|
|
}
|