Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java 5 Editing Paragraph Styles so will lose the marks. Please make sure you Upload your code files on designated folder before leaving. .

In java image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is the maximum penalty for HIPAA violation

Answered: 1 week ago

Question

what is a peer Group? Importance?

Answered: 1 week ago