Suppose a class GroceryBill keeps track of a list of items being purchased at a market: Mather

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Suppose a class GroceryBill keeps track of a list of items being purchased at a market:
Method/Constructor
Description
constructs a GroceryBill object for the given clerk
public GroceryBill(Employee clerk)
public void add(Item i)
public double getTotal()
public void printReceipt(0
adds i to this bill's total
returns the cost of these items
prints a list of items
GroceryBill objects interact with Item objects. An Item has the following public methods:
Method/Constructor
Description
returns the price for this item
public double getDiscount() returns the discount for this item
public double getPrice()
For example, a candy bar item might cost 1.35 with a discount of 0.25 for preferred customers, meaning that preferred customers
get it for 1.10. (Some items will have no discount, 0.0.) Currently the above classes do not consider discounts. Every item in a bill is
charged full price, and item discounts are ignored.
Define a class DiscountBill that extends GroceryBill to compute discounts for preferred customers. The constructor for
DiscountBill accepts a parameter for whether the customer should get the discount.
Your class should adjust the amount reported by getTotal for preferred customers. For example, if the total would have been $80
but a preferred customer is getting $20 in discounts, then getTotal should report the total as $60 for that customer. You should also
keep track of how many items a customer is getting a non-zero discount for and the overall discount, both as a total amount and as a
percentage of the original bill. Include the extra methods below that allow a client to ask about the discount:
Method/Constructor
Description
public DiscountBill(Employee clerk, boolean preferred) constructs discount bill for given clerk
public int getDiscountCount()
public double getDiscountAmount ()
public double getDiscountPercent ()
returns the number of items that were discounted, if any
returns the total discount for this list of items, if any
returns the percent of the total discount as a percent of what the
total would have been otherwise
If the customer is not a preferred customer the DiscountBill behaves at all times as if there is a total discount of 0.0 and no items
have been discounted.
Transcribed Image Text:Suppose a class GroceryBill keeps track of a list of items being purchased at a market: Method/Constructor Description constructs a GroceryBill object for the given clerk public GroceryBill(Employee clerk) public void add(Item i) public double getTotal() public void printReceipt(0 adds i to this bill's total returns the cost of these items prints a list of items GroceryBill objects interact with Item objects. An Item has the following public methods: Method/Constructor Description returns the price for this item public double getDiscount() returns the discount for this item public double getPrice() For example, a candy bar item might cost 1.35 with a discount of 0.25 for preferred customers, meaning that preferred customers get it for 1.10. (Some items will have no discount, 0.0.) Currently the above classes do not consider discounts. Every item in a bill is charged full price, and item discounts are ignored. Define a class DiscountBill that extends GroceryBill to compute discounts for preferred customers. The constructor for DiscountBill accepts a parameter for whether the customer should get the discount. Your class should adjust the amount reported by getTotal for preferred customers. For example, if the total would have been $80 but a preferred customer is getting $20 in discounts, then getTotal should report the total as $60 for that customer. You should also keep track of how many items a customer is getting a non-zero discount for and the overall discount, both as a total amount and as a percentage of the original bill. Include the extra methods below that allow a client to ask about the discount: Method/Constructor Description public DiscountBill(Employee clerk, boolean preferred) constructs discount bill for given clerk public int getDiscountCount() public double getDiscountAmount () public double getDiscountPercent () returns the number of items that were discounted, if any returns the total discount for this list of items, if any returns the percent of the total discount as a percent of what the total would have been otherwise If the customer is not a preferred customer the DiscountBill behaves at all times as if there is a total discount of 0.0 and no items have been discounted.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education