@@ -0,0 +1,2301 @@
+import java.util.Queue;%0Aimport java.util.concurrent.LinkedBlockingQueue;%0A%0A/**%0A * This class defines a FIFO dron object with its typical operations%0A * We had to define the Dron class in this way as it is not possible to implement an array of LinkedBlockingQueue directly %0A * in the Factory, as generics do not allow creating arrays with them, so in this way we could deal with this setback%0A * @author Pedro Manuel G%C3%B3mez-Portillo L%C3%B3pez%0A * @version 12.Oct.14%0A */%0Apublic class Dron%7B%0A%0A%09private boolean free;%0A%09private int time=0; //time when the dron gets called%0A%09private Queue%3CBox%3E dron;%0A%09private int numberBoxes; //number of boxes the dron is carring%0A%09%0A%09/**%0A%09 * The constructor of the class %0A%09 */%0A%09public Dron()%7B%0A%09%09dron = new LinkedBlockingQueue%3CBox%3E();%0A%09%09free = true;%0A%09%09numberBoxes=0;%09%0A%09%7D%0A%0A%09/**%0A%09 * This method returns the next box in delivering, but it does not delete from the dron%0A%09 * @return the next box in delivering, but it does not delete from the dron%0A%09 */%0A%09public Box top()%7B%0A%09%09return dron.element();%0A%09%7D%0A%0A%09/**%0A%09 * This method returns the String with the label of the next box in delivering%0A%09 * @return the label of the next box to deliver%0A%09 */%0A%09public String getLabel()%7B%0A%09%09return top().getLabelStorageUnit();%0A%09%7D%0A%0A%09/**%0A%09 * This method allows to add a new box to the dron%0A%09 * @param b the box we want to add%0A%09 */%0A%09public void addBox(Box b)%7B%0A%09%09numberBoxes++;%0A%09%09dron.add(b);%0A%0A%09%7D%0A%0A%09/**%0A%09 * This method extracts the next box to deliver from the dron%0A%09 * @return the current box of being delivered%0A%09 */%0A%09public Box getBox()%7B%0A%09%09numberBoxes--;%0A%09%09return dron.poll();%0A%09%09%0A%09%7D%0A%0A%09/**%0A%09 * Shows the occupancy of the dron (if its carrying boxes)%0A%09 * @return the occupancy of the dron: true if full false if empty%0A%09 */%0A%09public boolean isFree()%7B%0A%09%09return free;%0A%09%7D%0A%0A%09/**%0A%09 * Sets the occupancy of the dron%0A%09 * @param occ%0A%09 */%0A%09public void setFree(boolean f)%7B%0A%09%09free = f;%0A%09%7D%0A%09%0A%09/**%0A%09 * Saves the time when the dron got called%0A%09 * @param t%0A%09 */%0A%09public void setTime(int t)%7B%0A%09%09time=t;%0A%09%7D%0A%09%0A%09/**%0A%09 * Returns the time when the dron got called%0A%09 * @return the time when the dron got called%0A%09 */%0A%09public int getTime()%7B%0A%09%09return time;%0A%09%7D%0A%0A%09/**%0A%09 * This method returns the number of boxes the dron is carring%0A%09 * @return the number of boxes the dron is carring%0A%09 */%0A%09public int getNumberBoxes()%7B%0A%09%09return numberBoxes;%0A%09%7D%0A%0A%7D%0A

Create Dron.java