Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create an abstract class named Food with the following attributes: food _ ID ( int ) , food _ Name ( String ) , food
Create an abstract class named Food with the following attributes: foodID int foodName String foodPrice double where the foodID is a unique identifier that starts from the value your student ID and auto increments with each creation of a new child object of the Food class. Create a toString method that returns the values of the foodID foodName, and foodPrice for any Food object. Marks
Create Apple and Orange classes which inherit from the Food class, with the following additional attributes for each of the child classes: color String and taste String Create the Setters and Getters for all attributes. In addition, override the toString method that is inhereted from the Food class. None of the classes in the project should be able to inheret neither from the Apple nor the Orange classes. Marks
Create an interface named Your First Name with three methods as follows: Marks
void printFoodArrayList food;
Food searchMaxPriceArrayList food;
int countOrangesArrayList food;
The printFood method takes an ArrayList of Food objects as input and prints their details depending on the toString method defined in the Food class or any of its child classes Apple and Orange
The searchMaxPrice method takes an ArrayList of Food objects as input and returns the Food that has the maximum price it can be a generic Food object, an Apple or Orange
The countOranges method takes an ArrayList of Food objects as input and returns the number of Orange objects that are in the ArrayList.
Create a MainProgram class that implements the created interface. In the main method of the MainProgram class, create an ArrayList of Food objects and add three objects to the list as follows: one Apple object and two Orange objects. In the main method of the MainProgram class, call the three methods that have been implemented in the MainProgram class based on their definition in the interface. Marks
Upload your solution using NetBeans through Moodle, in one compressed file yournameyourID.zip
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