Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Example on abstract class and interface *Code in Java Suppose: There is a store that sells. Goods, each of which has the following attributes: a

image text in transcribed
image text in transcribed
Example on "abstract class and interface" *Code in Java Suppose: There is a store that sells. Goods, each of which has the following attributes: a description . a price (per item) a quantity (items on hand) And one method . a toString() The types of goods are: o Food -- with an attribute "calories". Food objects are not taxable Toy - with an attribute "minimumAge". Toy objects are taxable Book - with an attribute "author" Book objects are taxable. A Taxable item, Has a taxRate of 6 percent (0.06). Has a calculate Tax Omethod. Define a project with name Interface Concept to define these classes and the interface according to the following this UML abstract Goods interface -description: String Taxable price: double taxRote 10.00 *getters calculate Tax double setters .ToString String get TotalPrice) double is-a Food caloric double *constructor .toString String setter "getter get TotalPrice double Book author String constructor toString String calculate Tax ) double setter "getter get Tetor double Tay minimumAgeint constructor toString: String calculate Tax O double setter "getter Tetrice delle calculate Tax() implements as follow: price*tax get TotalPrice() implements as follow: in Food class quantity* price: in Book class quantity* (price price tax) in Toy class quantity* (price price*tax) .toString This method returns information of the all attributes as String data type. In main method: Create an object of three types Book Toy Food Print the information of these objects. Print description of toy object, tax value and total price. Change description of book object from OOP to Data Structures. Print new information after changing. * Print description of book object, tax value and total price. Print description of food object and total price. Output Interface Concept (run) 152 Toy : Description : lego Quantity:20 Minagae : 5 Tood: Description : Labana Price : 1.6 Quantity: 1 Calories: 3.0 Book : Description : DOP Price: 30.0 Quantity : 15 Author : Detiel Description of toys object is lego Tax of logo 10.3 Total Price of 30 Lego toys is 106.0 JD Change description of book object from OOP to Data Structure Book : Description : Data Structures Price : 30.0 Quantity : 15 Author : Detiel Description of book object is Data Structures Tax of Data Structures is 1.7999999999999998 Total Price of 15 Data Structures book is 422.0 JD Change quantity of food object from 1 to 4 Food : Description : Labana Price: 1.6 calories : 3.0 Description of food object is Labana Total Price of 4 Labana is 6.4 JD BULD SUCCESSFUL (total times seconds)

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

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Which team solution is more likely to be pursued and why?

Answered: 1 week ago

Question

4. I can tell when team members dont mean what they say.

Answered: 1 week ago