public class PartsList extends ModelComponent
WorkStation
in order to tell the work
station how many and of which kind of parts should be assembled there. The
user can instantiate a PartsList either by providing to arrays of the same
length, one with all the different kinds of parts and one with the respective
number of each different part, or by instantiating a PartsList with the
number of different kinds of parts and then adding pairs of [kindOfPart,
number of this kind of parts] using the addPart
method.Constructor and Description |
---|
PartsList(Model ownerModel,
java.lang.String name,
java.lang.Class[] kindsOfParts,
int[] numOfParts)
Constructs a PartsList with the given arrays of different kinds of parts
and the quantities of that kind of part.
|
PartsList(Model ownerModel,
java.lang.String name,
int numberOfDifferentParts)
Constructs a PartsList with enough space to store a number of different
kinds of parts with the respective quantity needed of each kind.
|
Modifier and Type | Method and Description |
---|---|
void |
addPart(java.lang.Class kindOfPart,
int numberOfParts)
Adds a pair of [kind of part, quantity of that kind of part] to the
PartsList.
|
int |
getIndexOfKind(java.lang.Class kind)
Returns the index of the given kind of part (
java.lang.Class ). |
java.lang.Class |
getKindOfPart(int index)
Returns the kind of the part at index i as a Class object.
|
java.lang.Class[] |
getKindOfParts()
Returns the whole array of all kinds of parts listed in this PartsList.
|
int |
getNumberOfDiffParts()
Returns the number of different parts (that is the number of entries) in
this PartsList.
|
int[] |
getNumberOfParts()
Returns the whole array of all the different quantities of all different
kinds of parts listed in this PartsList.
|
int |
getQuantityOfPart(int index)
Returns the quantity of the part at the index i of this PartsList.
|
current, currentEntity, currentEntityAll, currentEvent, currentModel, currentSimProcess, debugIsOn, debugOff, debugOn, getModel, isExperimentCompatible, isModelCompatible, presentTime, sendDebugNote, sendMessage, sendTraceNote, sendWarning, skipTraceNote, skipTraceNote, traceIsOn, traceOff, traceOn
getName, getQuotedName, toString
public PartsList(Model ownerModel, java.lang.String name, java.lang.Class[] kindsOfParts, int[] numOfParts)
ownerModel
- desmoj.Model : The model this PartsList is associated to.name
- java.lang.String : The name of this PartsList.kindsOfParts
- java.lang.Class[] : The array containing the different kinds
of parts.numOfParts
- int[] : The array constaining the number of each kind of part.public PartsList(Model ownerModel, java.lang.String name, int numberOfDifferentParts)
addPart
to add a pair of [kind of part, quantity of
that kind of part]. The PartsList leaves no messages in the trace.ownerModel
- desmoj.Model : The model this PartsList is associated to.name
- java.lang.String : The name of this PartsList.numberOfDifferentParts
- int : The number of different kinds of parts. Should not be
zero or negative!public void addPart(java.lang.Class kindOfPart, int numberOfParts)
getNumberOfDiffParts().
kindOfPart
- java.lang.Class : The kind of part as a Class object.numberOfParts
- int : The number of that kind of part.public int getIndexOfKind(java.lang.Class kind)
java.lang.Class
). The index is indicating the position in
the array of kindOfParts. If the given kind of part is not found in this
PartsList, undefinded (-1) will be returned.kind
- java.lang.Class : The kind of part given as an object of
java.lang.Class
.java.lang.Class
). That is the position in the
array of kindOfParts. Or undefined (-1) if no such kind of part
can be found in this PartsList.public java.lang.Class getKindOfPart(int index)
index
- int : The index in the PartsList for which the kind of the
part will be returned. The index runs from zero to
(numberOfDiffParts - 1).null
will be returned.public java.lang.Class[] getKindOfParts()
public int getNumberOfDiffParts()
public int[] getNumberOfParts()
public int getQuantityOfPart(int index)
index
- int : The index in the PartsList for which the quantity of the
part will be returned. The index runs from zero to
(numberOfDiffParts - 1).