Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a- Extend the Product class by adding two derived classes child classes and subclasses): ElectricProduct - FoodProduct b-Create the main class to display the attributes
a- Extend the Product class by adding two derived classes child classes and subclasses): ElectricProduct - FoodProduct b-Create the main class to display the attributes of Foodproduct object c- And add the following main/client class: import java.time. LocalDate; public class App\{ public static void main(String[]args)\{ Product p = new Product (1234, 9.99, "water"); FoodProduct p4 = new FoodProduct(3452, 10.0, "Cheddar Cheese", LocalDate.parse("2022-06-07")); ElectricProduct p5 = new ElectricProduct (4875,30.0, "Extension cord", "220v"); \} d- Question: The Product class should not be instantiated directly as done in the first line of the main method. Change the Product class, so only concrete classes should be instantiated. What changes would you make? Hint: You'll need to change the definition of the Product class. (to be non instantiable)
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