Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the products.java is: abstract class Product { protected float price; // return the price of a particular product abstract float price(); } //------------------------------------------------------------ class ComputerPart

image text in transcribed

the products.java is:

abstract class Product { protected float price;

// return the price of a particular product abstract float price(); }

//------------------------------------------------------------

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); } }

Part 1: (6096) 1. Carefully study the class structure in Products.java. 2. Design a generic container called GenericOrder that acts as a collection of an arbitrary number of objects in Products.java. Design a mechanism that 3. Design and implement a subclass of GenericOrder called ComputerOrder that takes an arbitrary number of different classes of ComputerPart objects, 4. Design and implement a subclass of GenericOrder called PartyTrayOrder that takes an arbitrary number of different classes of Cheese objects, Fruit 5. Design and implement a class called OrderProcessor. You must implement at least the following methods: gives each instance of the container a unique identifier. Implement as many methods as necessary. You must use Java generics features. Peripheral objects, and Service objects. Implement as many methods as necessary objects, and Service objects. Implement as many methods as necessary. accept; Wthis 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 Genericrder into collections of ComputerPart, Peripheral, Cheese, Fruit, and Service. You must associate each object with the unique identifier. You may refer to the TwoTuple.java example in the text book 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. 6. Create a client class to test OrderProcessor. You will need to create a datagenerator for testing purpose. It is not mandatory but you may use a variation of Data Generator in TIj pages 637 to 638. 7. Pack the above codes into one single zip file and send it to your tutor Part 2: (3596) 8. Design and implement a subclass of GenericOrder called ComputerPartyOrder that takes an arbitrary number of different classes of ComputerPart objects, Peripheral objects, Cheese objects, Fruit objects and Service objects 9. Create another client class that creates ComputerPartyOrder. Modify OrderProcessor if necessary 10. Pack the above codes into a second zip file and send it to your tutor

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions