item (-) id: String (-) description: String (-) unitPrice double (-) numberOfltem: int (+) item(id:String, description:String, unitPrice:double) (+) getNumberOfItem(): int (+) computeSalePrice(): double (+) toString(): String HouseholdItem (-) discount: double (+) HouseholdItem(discount:double) (+) computeSalePrice(): double (+) toString(): String Electronicltem (-) warrentyPeriod: int (-) warrentyCost: double (+) ElectronicItem(warrentyPeriod, warrentyCost) (+) computeSalePrice(): double (+) toString(): String

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter1: A First Program Using C#
Section: Chapter Questions
Problem 7RQ: The technique of packaging an objects attributes into a cohesive unit that can be used as an...
icon
Related questions
Question

In a shopping cart, there are various items, which can either belong to the category of household items or electronic items. The following UML diagram illustrates the relationship between items, household items, and electronic items.

 

//Implementation Class

public class ShoppingCart{

            public static void main(String[] args){

            final int MAX_ITEM = 50;

            Item cart = new Item[MAX_ITEM];

            addItem(cart); // populate the item array

           printItem(cart);

     }

}

Considering that all the data definition classes and the implementation class are complete, which of the following Object-Oriented Programming (OOP) concepts do you need to use in the above context?

i) Polymorphism

ii) Method Overloading

iii) Method Overriding

iv) Dynamic Binding

v) Abstract Class

Explain, using course terminology, how you would use any of the above concepts to model the given scenario.

item
(-) id: String
(-) description: String
(-) unitPrice double
(-) numberOfltem: int
(+) item(id:String, description:String, unitPrice:double)
(+) getNumberOfItem(): int
(+) computeSalePrice(): double
(+) toString(): String
HouseholdItem
(-) discount: double
(+) HouseholdItem(discount:double)
(+) computeSalePrice(): double
(+) toString(): String
Electronicltem
(-) warrentyPeriod: int
(-) warrentyCost: double
(+) ElectronicItem(warrentyPeriod, warrentyCost)
(+) computeSalePrice(): double
(+) toString(): String
Transcribed Image Text:item (-) id: String (-) description: String (-) unitPrice double (-) numberOfltem: int (+) item(id:String, description:String, unitPrice:double) (+) getNumberOfItem(): int (+) computeSalePrice(): double (+) toString(): String HouseholdItem (-) discount: double (+) HouseholdItem(discount:double) (+) computeSalePrice(): double (+) toString(): String Electronicltem (-) warrentyPeriod: int (-) warrentyCost: double (+) ElectronicItem(warrentyPeriod, warrentyCost) (+) computeSalePrice(): double (+) toString(): String
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr