n="justify"> createContainers (
int containersNum, ContainerTemplate ct,
int maxVolume,
int maxCargo) {r=
new Random ();
int volumeDiapasonLength=maxVolume - ct. getVolume (). getBegin ();
int cargoDiapasonLength=maxCargo - ct. getCargo (). getBegin ();
for ( int i=0; i lt; containersNum; i ++) {. add ( new Container (i + 1, r. nextInt (volumeDiapasonLength + 1) + ct. getVolume (). getBegin () ,. nextInt (cargoDiapasonLength + 1) + ct. getCargo (). getBegin ()));
}
this . containersSequence= new int [containersNum];
for ( int i=0; i lt; containersNum; i ++) {[i]=containers. get (i). getId ();
}= new LinkedList lt; List lt; Integer gt; gt; (); (templates, containersSequence, containersNum);= new TreeMap lt; Container, List lt; Item gt; gt; ( new MapKeysComparator (0));
for (Container c: containers) {. put (c, new LinkedList lt; Item gt; ());
}
}
/**
* Створити впаковують об'єкти.
* @ param itemsNum Число об'єктів.
* @ param it Шаблій об'єкта.
* @ param maxVolume Обмеження за обсягом.
* @ param maxWeight Обмеження по масі.
*/
public void createItems ( int itemsNum, ItemTemplate it, int maxVolume, int maxWeight) {
int volumeDiapasonLength=maxVolume - it. getVolume (). getBegin ();
int weightDiapasonLength=maxWeight - it. getWeight (). getBegin ();
int r1DiapasonLength=it. getRate1 (). getEnd () - it. getRate1 (). getBegin ();
int r2DiapasonLength=it. getRate2 (). getEnd () - it. getRate2 (). getBegin ();
int r3DiapasonLength=it. getRate3 (). getEnd () - it. getRate3 (). getBegin ();
int r4DiapasonLength=it. getRate4 (). getEnd () - it. getRate4 (). getBegin ();
int r5DiapasonLength=it. getRate5 (). getEnd () - it. getRate5 (). getBegin ();
for ( int i=0; i lt; itemsNum; i ++) {. add ( new Item ((i + 1) + raquo ;, r. nextInt (volumeDiapasonLength + 1) + it. getVolume (). getBegin () ,. nextInt ( weightDiapasonLength + 1) + it. getWeight (). getBegin () ,. nextInt (r1DiapasonLength + 1) + it. getRate1 (). getBegin () ,. nextInt (r2DiapasonLength + 1) + it. getRate2 (). getBegin () ,. nextInt (r3DiapasonLength + 1) + it. getRate3 (). getBegin () ,. nextInt (r4DiapasonLength + 1) + it. getRate4 (). getBegin () ,. nextInt (r5DiapasonLength + 1) + it. getRate5 (). getBegin ()));
}
}
/**
* @ return the containers
*/
public List lt; Container gt; getContainers () {
return containers;
}
/**
* @ return the items
*/
public List lt; Item gt; getItemsClones () { lt; SimpleEntry lt; String, String gt; gt; itemPairs= new ArrayList lt; SimpleEntry lt; String, String gt; gt; (); lt; Item gt; newItems= new ArrayList lt; Item gt; ();
for (Item i: items) {. add (i. clone ());
if (i. hasPair ()) {. add ( new SimpleEntry lt; String, String gt; (i. getId (), i. getPair (). getId ()));
}
}
for (Entry lt; String, String gt; e: itemPairs) {(e. getKey (), newItems). setPair (getItemFromListByID (e. getValue (), n...