Question: In java 5 Editing Paragraph Styles so will lose the marks. Please make sure you Upload your code files on designated folder before leaving. .
5 Editing Paragraph Styles so will lose the marks. Please make sure you Upload your code files on designated folder before leaving. . 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 I for initializing expiry Date and ask user to enter the price and set it calling method set Price (int). 14 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 ealling its readyToSellO method. 12 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
