Exemple #1
0
 /**
  * Sets the workstations of this shop.
  *
  * @param machines An array containing all workstations for this shop.
  */
 public void setMachines(WorkStation[] machines) {
   this.machines = machines.clone();
   int i = 0;
   for (WorkStation w : machines) {
     w.shop = this;
     w.index = i++;
   }
 }
Exemple #2
0
  /**
   * Adds a single machine to this shop.
   *
   * @see #getMachines()
   * @param machine The workstation to add.
   */
  public void addMachine(WorkStation machine) {
    ArrayList<WorkStation> list = new ArrayList<WorkStation>(Arrays.asList(machines));
    list.add(machine);

    machine.shop = this;
    machine.index = list.size() - 1;

    machines = list.toArray(new WorkStation[list.size()]);
  }
Exemple #3
0
 /**
  * Removes a machine from this shop.
  *
  * @param machine The workstation to remove.
  */
 public void removeMachine(WorkStation machine) {
   ArrayList<WorkStation> list = new ArrayList<WorkStation>(Arrays.asList(machines));
   if (list.remove(machine)) {
     machine.shop = null;
     machine.index = -1;
     int i = 0;
     for (WorkStation w : list) {
       w.index = i++;
     }
     machines = list.toArray(new WorkStation[list.size()]);
   }
 }