Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
Example on "abstract class and interface" 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: 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 ( method. 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 +taxRate :0.06 quantity int *getters calculate Tax ( double +toString O: String get TotalPrice (). double *setters is-a is-a Food -calories double +constructor +toString(): String *setter gefter *get TotalPrice ) double Book -author: String *constructor +toString: String calculate Tax : double *setter *gefter *get TotalPrice () double -minimumAge: int constructor +toString: String *calculate Tax O: double setter *getter get TotalPrice ( double 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) .toStringo 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 (ru) Toy : Description : lego Price: 5.0 Quantity 20 Ninagaes Food Description : Labana Price: 1.6 Quantity: 1 Calories: 3.0 Book Description : OOP Price: 30.0 Quantity : 15 Author : Detiel Description of toys object is lego Tax of logo is 0.3 Total Price of 20 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.799999999999999 Total Price of 15 Data Structures book is 477.0 JD Change quantity of food object from 1 to 4 Food : Description : Labana Price: 1.6 Quantity: Calories : 3.0 Description of food object is Labana Total Price of Labana is 6.4 JD BUILD SUCCESSFUL (total 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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions