Question
Design and implement a class called OrderProcessor. You must implement at least the following methods: accept; // this method accepts a GenericOrder or any of
Design and implement a class called OrderProcessor. You must implement at least the following methods:
accept; // this method accepts a GenericOrder or any of its subclass objects and stores it in any internal collection of OrderProcessor.
process; // this method sorts all accepted orders in the internal collection of GenericOrder into collections of ComputerPart, Peripheral, Cheese, Fruit, and Service. You must associate each object with the unique identifier.
dispatchXXX; // this method simulates the dispatch of the sorted collections. For example, the method dispatchComputerParts() should produce this output:
Motherboard name=Asus, price=$37.5, order number=123456
Motherboard name=Asus, price=$37.5, order number=987654
RAM name=Kingston, size=512, price=$25.0, order number=123456
You may overload each of the above methods as you think necessary.
/////////////////////////////////Supplied Code//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
abstract class Product { protected float price;
// return the price of a particular product abstract float price(); }
//------------------------------------------------------------ class GenericOrder
ArrayList
} public void remove(T item) {
list1.remove(item); } public T get (int index){
return list1.get(index); } public int GetID(){
return ID; } }
class ComputerPart extends Product { public ComputerPart(float p) { price = p; }
public float price() { return price; } }
class Motherboard extends ComputerPart { protected String manufacturer; public Motherboard(String mfg, float p) { super(p); manufacturer = mfg; } public String getManufacturer() { return manufacturer; } }
class RAM extends ComputerPart { protected int size; protected String manufacturer; public RAM(String mfg, int size, float p) { super(p); this.manufacturer = mfg; this.size = size; } public String getManufacturer() { return manufacturer; } }
class Drive extends ComputerPart { protected String type; protected int speed; public Drive(String type, int speed, float p) { super(p); this.type = type; this.speed = speed; } public String getType() { return type; } public int getSpeed() { return speed; } }
class Peripheral extends Product { public Peripheral(float p) { price = p; } public float price() { return price; } }
class Printer extends Peripheral { protected String model; public Printer(String model, float p) { super(p); this.model = model; } public String getModel() { return model; } }
class Monitor extends Peripheral { protected String model; public Monitor(String model, float p) { super(p); this.model = model; } public String getModel() { return model; } }
class Service extends Product { public Service(float p) { price = p; } public float price() { return price; } }
class AssemblyService extends Service { String provider; public AssemblyService(String pv, float p) { super(p); provider = pv; } public String getProvider() { return provider; } }
class DeliveryService extends Service { String courier; public DeliveryService(String c, float p) { super(p); courier = c; } public String getCourier() { return courier; } }
//------------------------------------------------------- class Cheese extends Product { public Cheese(float p) { price = p; } public float price() { return price; } }
class Cheddar extends Cheese { public Cheddar(float p) { super(p); } } class Mozzarella extends Cheese { public Mozzarella(float p) { super(p); } }
class Fruit extends Product { public Fruit(float p) { price = p; } public float price() { return price; } } class Apple extends Fruit { public Apple(float p) { super(p); } } class Orange extends Fruit { public Orange(float p) { super(p); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started