Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // if a cyclist (and a pizza) is available then let them deliver the next pizza from the queue
- for(Map.Entry<Integer, Integer> i : cyclists.entrySet()){
- if (time > i.getValue() && !queue.isEmpty()) {
- // obtain next pizza from the queue
- Pizza deliveredPizza = queue.poll();
- // is it impossible to deliver this pizza on time?
- if (time + deliveredPizza.deliveryTime() > deliveredPizza.deadline()) {
- // refund the pizza price with a penalty factor applied
- total -= deliveredPizza.latePrice();
- // update the late pizza counts
- if (deliveredPizza.isUrgent())
- countLateUrgent++;
- else
- countLateStandard++;
- } else // delivery on time was possible
- countOnTime++;
- // calculate busy time for cyclist
- int fullTripTime = 2 * deliveredPizza.deliveryTime();
- // update profit tally with delivery cost
- total -= Pizza.PerMinuteDeliveryCost * fullTripTime;
- cyclists.put(i.getKey(), time+fullTripTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement