|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
Plant
public class Plant
This class simulates a Plastics Injection molding plant that has a single large hopper for pellets and can have any number of molding machines and any number of storage areas. We only make plastic containers that require exactly 500 gms of pellets. Each machine can have a different production rate and each storage area can hold a different amount of containers. When containers are shipped they are removed from storage areas always starting from the first storage area (index 0).
| Constructor Summary | |
|---|---|
Plant()
Creates a new instance of Plant |
|
Plant(java.lang.String id,
double hopperSize)
Constructor for Plant that initializes key variables. |
|
| Method Summary | |
|---|---|
void |
addMachine(java.lang.String id,
int productionRate)
Add a machine to the list of machines. |
void |
addPellets(double kg)
Add a specified amount of plastic pellets to the Hopper. |
void |
addStorageArea(int capacity)
Add a storage area to the list of storage areas. |
int |
getAvailableStorage()
Gets the total room available in all storage areas by iterating through all storage areas and adding the available room in each. |
int |
getAvailableStorage(int location)
Gets the room available in a specific storage area. |
double |
getHopperSize()
Returns hopper size (kg). |
java.lang.String |
getName()
Returns plant name. |
double |
getPellets()
Returns the amount of pellets in the hopper (kg). |
int |
getProductionCapacity()
Returns production capacity of the entire plant. |
int |
getStock()
Gets the total amount of parts in all storage areas by iterating through all storage areas and adding the stock in each. |
int |
getStock(int location)
Gets the stock that is to be found in a specific storage area specified by its index. |
void |
run(int minutes)
Run the plant for a specified number of minutes or until a NotEnoughPelletsException or NoMoreStorageException occurs whichever comes first. |
int |
runStatus()
Returns the total number of minutes the plant ran during the last call to the run() method. |
void |
setHopperSize(double hopperSize)
Sets the hopper size (in Kg). |
void |
setName(java.lang.String name)
Sets plant name. |
void |
setPellets(double kg)
Set the amount of pellets in the Hopper to the value of the parameter. |
void |
shipParts(int count)
Method will attempt to ship parts from the storage areas. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Plant()
public Plant(java.lang.String id,
double hopperSize)
id - Name of plant.hopperSize - Size of hopper in kg.| Method Detail |
|---|
public java.lang.String getName()
public void setName(java.lang.String name)
name - Name of plant.public double getHopperSize()
public void setHopperSize(double hopperSize)
hopperSize - Hopper size in kg.public double getPellets()
public void setPellets(double kg)
throws HopperFullException
kg - Amount of pellets (in kg).
HopperFullException - Thrown when adding or setting Hopper size exceeds Hopper capacity.public void addPellets(double kg)
throws HopperFullException
kg - Amount of pellets to add (in kg).
HopperFullException - Thrown when adding pellets will exceed hopper capacity.public void addStorageArea(int capacity)
capacity - Capacity of the new storage area.public void addMachine(java.lang.String id,
int productionRate)
id - Id of the new machine as a String.productionRate - Production rate in parts per minute.public int getProductionCapacity()
public int getAvailableStorage()
public int getAvailableStorage(int location)
throws StorageLocationException
location - Index of a storage area.
StorageLocationException - On index out of range.public int getStock()
public int getStock(int location)
throws StorageLocationException
location - Index of storage area.
StorageLocationException - if the location is not within rangepublic void shipParts(int count)
throws NotEnoughPartsException
count - Number of parts to be shipped.
NotEnoughPartsException - When there are insufficient parts to ship.public void run(int minutes)
throws NoMoreStorageException,
NotEnoughPelletsException
minutes - No of minutes to run the plant.
NoMoreStorageException
NotEnoughPelletsExceptionpublic int runStatus()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||