Question: Classes required: public class GroceryBill { // FIELDS private Employee clerk; protected List receipt; private double total; private double internalDiscount; // CONSTRUCTORS public GroceryBill(Employee name)

Classes required:
public class GroceryBill { // FIELDS private Employee clerk; protected List
// Iverson requires zero parameter constructor public GroceryBill() { this(null); }
// MUTATORS (modifiers) public void add(Item i) { receipt.add(i); total += i.getPrice(); internalDiscount += i.getDiscount(); } // ACCESSORS (getters) public double getTotal() { return Math.rint(total * 100) / 100.0; } public Employee getClerk() { return clerk; } // private methods are called "helper" methods private String valueToString(double value) { value = Math.rint(value * 100) / 100.0; String result = "" + Math.abs(value); if(result.indexOf(".") == result.length() - 2) { result += "0"; } result = "$" + result; return result; } // complicated toString methods for Practice-IT output public String receiptToString() { String build = "items: "; for(int i = 0; i
}
public class Item { private String name; private double price; private double discount; public Item(String name, double price, double discount) { this.name = name; this.price = price; this.discount = discount; } public double getPrice() { return price; } public double getDiscount() { return discount; } private String valueToString(double value) { String result = "" + Math.abs(value); if(result.indexOf(".") == result.length() - 2) { result += "0"; } result = "$" + result; return result; } public String toString() { return name + " " + valueToString(price) + " (-" + valueToString(discount) + ")"; } }
public class Employee { private String name; public Employee(String name) { this.name = name; } public String getName() { return name; } }
Submit DiscountApp.java which must extend GroceryBill D from Chapter 9 This programming project in our textbook has scant details, so I've wrote my own. It was based on the Discount Bill and GroceryBill from Chapter 9a, but a serious design flaw was uncovered: The "total" and "discount" in those textbook classes are always increase (+=) so we can never remove anything from the list. When you make a functioning shopping app, we need to be able to add AND remove items, so a design change is required. Bottom line, OK to extend GroceryBill, but total and discount must be recomputed in our subclass. In summary: Textbook ItemOrder will not be needed, because we can simply use Item from Chapter 9, and just add (or remove) Item objects in ArrayList needed. . With the simple change to "protected List" in the GroceryBill.java we can manipulate the ArrayList Search the ArrayList, managing size, super.add and remove become the major conceptual tasks in getting this project to work. Above specifications will impose good object-oriented programming (OOP) by using class methods to manipulate the object. DiscountApp.java minimum specifications: boolean for discount one data field (NO more, others inherited) two constructors zero parameter and single parameter int number of Item's now purchased, return true upon add(Item, int) method success getTotal() method returns double, checks for discounts, cannot use super total set Discount(boolean) method toString() standard simple one line of code, allows GUI App to work calls toString() for all Items in cart In your solution, most coding is for add and getTotal, as they need to rework the List every time. Why the name "event driven Shopping"? Because we all must know that "event driven" programs are, as we use them constantly in daily life. Whenever an "event" happens, like a click or edit or data change, then some code is run and things happen, main() is not that important. I implement from Oracle, the ActionListener and extend JFrame so each "event" like a click or tab or enter key runs a method that calls your methods that totals our shopping cart in the app. It
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
