Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a class named Food with the following specifications: (1 points) Name the class Food (3 points) Create the following instance variables: String name,
Write a class named Food with the following specifications: (1 points) Name the class Food (3 points) Create the following instance variables: String name, double weight, and String taste (2 points) Create a constructor that will be blank (4 points) Create another constructor that will take in three arguments: name, weight and taste. Use the this keyword to assign the instance variables values based on the arguments passed in by the constructor. HINT: public Food(String name, int weight, String taste) (12 points) Create an accessor (aka get) and a mutator (aka set) method which will get and set the weight and taste instance variables of the Food class. (Total of 4 methods) (3 points) Create a method called "public String data()". This method will return a String which will contain the name, weight, and taste of the fruit.
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