Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in java language(oop) e Question 1: [30 Marks] Create an interface Price with one abstract method setPrice(int). [2 Marks] Create an abstract class Item which
in java language(oop)
e Question 1: [30 Marks] Create an interface Price with one abstract method setPrice(int). [2 Marks] Create an abstract class Item which implements Price interface with a method sell(Obect o) which calls the toString() of the respective subclass object after downcasting. [2 marks] Extend a class Milk from Item class which contains one protected data member Brand (String), and one private data member expiry Date (Date).. [5 Marks] Provide constructor for Milk class with one parameter String to initialize value of Brand and another parameter to initialize date. Also call the interface's setPrice method and pass it the value asked from user. [3 Marks] Write a method featuresofProduct() so that it will display the Brand, expiry Date and price of the product. [2 Marks] Create a class flavored Milk and extend it with the Milk class. Also declare its private data member String to store the flavour as string [2 Marks] Write constructor for the flavored Milk class with two strings for flavour and brand, a date object for initializing expiry Date and ask user to enter the price and set it calling method setPrice (int). [4 Marks] Override toString() method in the flavored Milk by concatenating output of toString of the Milk class. [5 Marks] Create a method readyToSello in flavored Milk class and in the body of that method call sell (Object o) to show indirect association of flavored Milk class with Item class. [3 Marks] Write a test class to demonstrate the working of the program by instantiating flavored Milk class and calling its readyToSello) method. [2 marks]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