Question
Just need this class, java language please The Food class has a String for name, a String for the unit type, a double for the
Just need this class, java language please
The Food class has a String for name, a String for the unit type, a double for the price per unit, a double for the amount of stock (which is in terms of the unit type defined), and the number of calories per unit. Food has a single constructor, which takes the name, unit, price, stock amount, and calories per unit, and sets all of the values of the current object accordingly.
Food has getters for fat (in percentage of calories), sugar (in percentage of calories), protein (in percentage of calories), name, price, and calories per unit, and they are called getFat(), getSugar(), getProtein(), getName(), getPrice(), and getCaloriesPerUnit() respectively. Food also has a method called decreaseStock which takes the amount of stock (in the units of the food item) to remove from the inventory. If there is enough stock to remove, remove the required amount and return true. Otherwise, return false and do not remove any stock. Finally, Food has an override for toString which prints the name of the food item, followed by , , followed by the price per unit in the format of $ followed by the price followed by / followed by the unit, which is followed by , and the amount of stock remaining, followed by and the unit for this food item, followed by in stock..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started