write a java classes A. Food Class 1. The food class is defined by the three following properties: name of the item, amount of calories and the weight usually measured in grams. 2. Create a constructor that takes as arguments the name, weight and amount of calories. Initialize the variable accordingly. 3. You will need to retrieve the amount of calories later on. Add the necessary method. 4. A toString method that returns the name of the item and its weight. Sample: 100 grams of rice B. Meal Class 1. The meal class is defined by two properties: a. Name b. An ArrayList of Food objects that represents the food items of that specific meal 2. Create a constructor that takes as argument the name of the meal. Initialize the variables accordingly. 3. Add the following methods to your class: a. addFood method that takes as argument a Food object and has no returned value. The method adds a Food item to the ArrayList of foods.
write a java classes A. Food Class
1. The food class is defined by the three following properties: name of the item,
amount of calories and the weight usually measured in grams.
2. Create a constructor that takes as arguments the name, weight and amount
of calories. Initialize the variable accordingly.
3. You will need to retrieve the amount of calories later on. Add the necessary
method.
4. A toString method that returns the name of the item and its weight.
Sample:
100 grams of rice
B. Meal Class
1. The meal class is defined by two properties:
a. Name
b. An ArrayList of Food objects that represents the food items of that specific
meal
2. Create a constructor that takes as argument the name of the meal. Initialize
the variables accordingly.
3. Add the following methods to your class:
a. addFood method that takes as argument a Food object and has no
returned value. The method adds a Food item to the ArrayList of foods.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images