Question: Please do in Java. Thank you Fou will be creating classes and methods for a grocery store. Every item sold in a grocery store has

 Please do in Java. Thank you Fou will be creating classesand methods for a grocery store. Every item sold in a grocerystore has a UPC (Universal Product Code) which is a numeric string.Create package com beans Create an abstract class called Item in thecom.beans package with the attributes below. The Constructor takes parameters in the

Please do in Java. Thank you

Fou will be creating classes and methods for a grocery store. Every item sold in a grocery store has a UPC (Universal Product Code) which is a numeric string. Create package com beans Create an abstract class called Item in the com.beans package with the attributes below. The Constructor takes parameters in the following order: the UPC and item's name. Create getters and setters. # com.beans Item upc: String .name : String Item(String, String) .getUpc(): String setUpc(String): void .getName(): String setName(String): void Create class called Groceryltem in the com.beans package. GroceryItem extends Item. Grocery items have additional class variables: company (for the company that makes the item ... for example: Kellogg's), the price of the item, and a loyalty code (which we'll explain in a bit). Create two constructors. One constructor will have parameters in the following order: UPC, item name, company, and price. The second constructor will have parameters in the following order: UPC, item name, company, price, and loyalty code. Create all getters and setters. Override the toString method. The class outline is shown on the next page. # com.beans Groceryltem e company: String . price: double loyaltyCode: String Groceryltem(String. String, String, double) Groceryltem(String, String, String, double, String) getCompany: String setCompany(String): void .getLoyaltyCode(): String SetLoyaltyCode(String): void getPrice: double setPrice(double): void toString(): String Grocery stores have loyalty cards. Customers with loyalty cards can save money on some groceries. This store has three types of deals: buy one get one, a percentage discount (ex: 10%), and a flat discount (ex: save 50 cents). Create an enum called DealType in the com.beans package and add the enums listed: com.beans DealType SF BUY_ONE_GET_ONE SF PERCENT_DISCOUNT SF FLAT_DISCOUNT Every loyalty deal has a UPC associated to it and a name for the type of deal it is. Create a LoyaltyDeal class in the com.beans. LoyaltyItem extends Item.. Loyalty deals have additional class variables: A deal type and a discount value. Create two constructors. One constructor will have parameters in this order: UPC, name, and deal type. The other constructor will have parameters in this order: UPC, name, deal type, and discount. Create getters and setters and override toString. The class outline is on the next page. # com.beans LoyaltyDeal . dealType: DealType discount : double LoyaltyDeal(String, String, DealType) LoyaltyDeal(String, String, DealType double) getDealType(): DealType setDealType(DealType) : void getDiscount(): double set Discount(double): void toString(): String Create a Demo class in the com.runner package. Copy and paste in the following code into your main method: public static void main(String[] args) { LoyaltyDeal] loyals = new LoyaltyDeal[4]; loyals[0] = new LoyaltyDeal ("70001", "BOGO", DealType.BUY_ONE_GET_ONE); loyals[1] new LoyaltyDeal("70002", "10% Off", DealType.PERCENT_DISCOUNT, 10); loyals[2] = new LoyaltyDeal ("70003", "50 Cents Off", DealType.FLAT_DISCOUNT, 0.5); loyals[3] = new LoyaltyDeal ("70004", "5% Off", DealType. PERCENT_DISCOUNT, 5); GroceryItem[] items = new GroceryItem[8]; items [0] = new Grocery Item("123", "Corn Flakes", "Kellogg's", 2.98); items[1] new Grocery Item("400", "Cupcakes", "Sunny", 3.19, "70001"); items [2] = new GroceryItem("201", "Paper Towels", "Pow", 2.60); items [3] = new Grocery Item("700", "Swiss Cheese", "Happy Cow", 2.99,"70001"); items [4] = new Grocery Item("305", "Corn Flakes", "Yum", 3.00, "70002"); items [5] = new Grocery Item("501", "Corn Flakes", "Big Box", 2.94, "70004"); items[6] = new Grocery Item("901", "Bleach", "Pow", 1.05); items [7] = new Grocery Item("305", "Corn Flakes", "Sunny", 3.30, "70003"); double price = GroceryUtilities. adjustUPCItemCost(items[2], 10); System.out.println(price + " should equal items [2].getPrice); + System.out.println(); Grocery Item[] dealItems = GroceryUtilities.getALlItemsForLoyaltyDeal (items, loyals[0]); for (GroceryItem dealItem: dealItems) { System.out.println(dealItem); } METHOD THREE public static HashSet

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!