import java.io.*; import java.util.*; public class Warehouses { public static void main(String[] args) throws IOException { if (args.length == 0 || args[0].equals("-h")){ System.out.println("\nDrone Delivery Depot Placement Problem (DDDPP) version 20161214 \n"+ "-d INT depot fixed cost (default is 500) \n"+ "-p DOUBLE point size (default 2.0) \n"+ "-l do not draw lines \n"+ "-h >java Warehouses depotLocations customerLocations"); return; } int fixedCost = 2500; double pointSize = 2.0; boolean drawLines = true; double maxDistance = 150.01; // max distance a drone can travel boolean legal = true; // if all distances are less than maxDistance for (int i=0;i hull = d.convexHull(); StdDraw.setPenColor(StdDraw.BLACK); if (drawLines) for (Point p : d.customers){ StdDraw.setPenColor(StdDraw.BLACK); double distance = Point.distanceEuclidean(p,d.location); if (distance < maxDistance) StdDraw.line(d.location.x,d.location.y,p.x,p.y); else { StdDraw.setPenColor(StdDraw.RED); StdDraw.line(d.location.x,d.location.y,p.x,p.y); legal = false; } } StdDraw.setPenColor(StdDraw.BLACK); if (hull.size() > 1){ Point v = hull.get(hull.size()-1); for (Point w : hull){ StdDraw.line(v.x,v.y,w.x,w.y); v = w; } } StdDraw.setPenColor(StdDraw.RED); StdDraw.filledSquare(d.location.x,d.location.y,3*pointSize); //try{Thread.currentThread().sleep(2000);} catch (InterruptedException e){} } StdDraw.setPenColor(StdDraw.BLACK); if (legal) StdDraw.textLeft(xMin,yMin,args[0] +" cost: "+ String.format("%.2f",totalCost) +" legal"); else StdDraw.textLeft(xMin,yMin,args[0] +" cost: "+ String.format("%.2f",totalCost) +" illegal"); } }