Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

prereshable.java: //Anick /** * Produce class inherits from ProductType. * Produce can be marked down. When a regular priced product is * marked down it becomes sale. A sale item marked down becomes...

1 answer below »
prereshable.java:
//Anick   /** * Produce class inherits from ProductType.   * Produce can be marked down. When a regular priced product is * marked down it becomes sale. A sale item marked down becomes clearance and is  * also moved to the clearance rack. In other words, a product moves down one level for each  * markdown. A clearance item cannot be marked down any further. */  public class Perishable extends ProductType { 	boolean clearanceBin; 	 	public void setClearanceBin(boolean moveToBin) { 		this.clearanceBin = moveToBin; 	}  	public boolean getClearanceBin() {  		return this.clearanceBin;  	} 	 	  	public static void main(String[] args) { 		// add testing code here  	}  }
-------------------------------------------------------------
Product.java:
//Anick  /** * Defines product by bar code, item name, and product type */ public class Product {  	private String code; // bar code 	private String item; // name of the item 	private ProductType type; // produce or canned  	/** 	 * 3-arg constructor 	 */ 	public Product(String c, String i, ProductType t) { 		this.code = c; 		this.item = i; 		this.type = t; 	}  	// mutator method 	public void setType(ProductType t) { 		this.type = t; 	}  	// accessor methods 	public String getCode() { 		return this.code; 	}  	public String getItem() { 		return this.item; 	}  	public ProductType getProductType() { 		return this.type; 	}  	 	public static void main(String[] args) { 		// Some testing code to get you started 		Perishable per= new Perishable("Sale", false); 		Product oranges = new Product(" XXXXXXXXXX", "Oranges", per); 		System.out.println(oranges); 		System.out.println(oranges.getProductType().markDown()); 		System.out.println(oranges);  	} }
----------------------------------------------------------
ProductType.java
/** Abstract superclass that represents the product type of a product.   *  Has one abstract method - markDown - which must be overridden in subclasses.  *  Defines the pricing instance variable for all products  */  //LEAVE THIS FILE UNCHANGED - do not submit  public abstract class ProductType { 	private String pricing; 	 	public ProductType(String p){ 		this.pricing = p; 	}  	public String getPricing() { 		return pricing; 	}  	public void setPricing(String p) { 		this.pricing = p; 	}  	public String toString() { 		return "Product Pricing: " + this.pricing; 	} 	 	/** ABSTRACT must be overridden in concrete subclasses 	 * Returns a boolean indicating if the product is on sale  	 */ 	public abstract boolean markDown(); }
----------------------------------------------------------
ShelfStable.java
//Anick   /** * ShelfStable class inherits from ProductType.   * Products that are ShelfStable cannot go on sale, nor go on clearance. * Their pricing is always regular. * ShelfStable items can be put on display at the end of an aisle. */  public class ShelfStable extends ProductType { 	private boolean endDisplay; 	 	public boolean isEndDisplay() { 		return endDisplay; 	}   	public void setEndDisplay(boolean e) { 		this.endDisplay = e; 	}  	 	/** A shelf stable product cannot be marked down  */ 	public boolean markDown() { 		return false; 	} 	  	public static void main(String[] args) { 		// add testing code here  	} }
----------------------------------------------------------
Store.java
//Anick  import java.util.ArrayList;  /** * This class maintains a 'database' of faculty members in an ArrayList instance * variable for a department in a college. It provides functionality for finding * a faculty member in the department by id, adding new faculty, removing faculty, * and creating lists of faculty by type (tenure-track: all, with tenure, without * tenure, instructor: all, union members, non-union). */  public class Store { 	private String name; 	private ArrayList products; // products sold at the store  	public Store(String n) { 		this.name = n; 		this.products = new ArrayList(); 	}  	// accessor method for name instance variable 	public String getName(){ return this.name; }  	/** accessor method for products instance variable that 	     returns the list of products sold as an array (for use in GUI interface) */ 	public Product[] getProducts(){ 		return this.products.toArray(new Product[this.products.size()]); 	}  	/** Returns a string description of each product sold at the store, 	 *  including their bar code, name, and clearanceBin or endDisplay status, depending on 	 *  product type */ 	public String toString() { 		String result = ""; 		for (Product prod : this.products) 			result += prod + "\n"; // one line per product 		return result; 	}   	public static void main(String[] args) { 		// some code to get you started 		Store store = new Store("Mr. Hooper's"); 		 		store.add(new Product(" XXXXXXXXXX", "Spagetti", new ShelfStable(true)));		 		store.add(new Product(" XXXXXXXXXX", "Milk", new Perishable("Regular", false))); 		 		System.out.println(store); 	 	} }
Answered Same Day Nov 25, 2021

Solution

Aditya answered on Nov 30 2021
153 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here