Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part A) Write a class BagelsOrderItem that implements the OrderItem interface. Implement your class in accordance with the encapsulation principle. Provide one constructor that takes

Part A) Write a class BagelsOrderItem that implements the OrderItem interface. Implement your class in accordance with the encapsulation principle. Provide one constructor that takes two parameters: double price and int quantity. Provide accessor methods that return the items price and quantity. BagelsOrderItems getCost method should return price times quantity. Write the entire BagelsOrderItem class, including all necessary instance variables and methods.

Part B ) Write a class BakersDozen, a subclass of BagelsOrderItem. A BakersDozen object represents an order of 13 bagels, which includes one free bagel. Provide one constructor that takes one parameter, double price (the quantity is known: it is 13). Override BagelsOrderItems getCost method to reflect one free bagel. Do not duplicate the instance variables of BagelsOrderItem class in BakersDozen. Write class BakersDozen below.

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

Students also viewed these Databases questions