@Override public void robotTakenBook(Robot robot, Desk desk, Book book, Environment environment) { // Dostarczanie z biurka if (robot.getCache().contains(book) && currentTasks.get(robot).getSourceDesk().equals(desk)) { // System.out.println("Robot: " + robot.getName() + " ma w kieszeni książkę: " + book + " // którą dosatrczy na półkę."); if (robot.getCacheSize() > robot.getCache().size()) { recentTasks.put(currentTasks.get(robot), robot); this.getNewCurrentTask(robot); } } }
private Task getNewTaskFromQueue(Queue<Task> queue, Robot robot) { Task task = null; for (int i = 0; i < robot.getCacheSize(); i++) { if (queue.peek() != null) { task = queue.poll(); robotTasks.put(task, robot); } } if (task != null) { currentTasks.put(robot, task); } return task; }