import java.util.concurrent.TimeUnit; public class RoadSensor { private boolean hazardDetected; //flag for whether a hazard is detected private String roadwayDetails; //stores road quality details, eg wet, uneven private double[] laneEdges; //stores distance to left/right lane edges private String roadSigns; //stores roadsign text for visible signs public void detectLaneEdges() { laneEdges[0] = 1; laneEdges[1] = 1.1; } public int detectSpeedLimit() { //image intepretation api call to review any street signs with a speed limit marking //in practice this will be combined with route mapping data to confirm current //speed limits return 45; } public static boolean identifyHazard() { //image processing algorithms from external cameras would //review data and identify a hazard //types of hazards could be //Stopped vehicle //Road construction //lane closure //pedestrian on roadway //stationary object on roadway //for testing purposes, this function will roll a 1/100 chance of detecting a hazard //and a value of 1 means a hazard was detected double detection = Math.floor(Math.random()*100); if (detection == 1) { return true; } else { return false; } } public static boolean detectTrafficLight() { //rolls a 1 in 5 that a traffic light will be detected when approaching an intersection double detection = Math.floor(Math.random()*5); if (detection == 1) { return true; } else { return false; } } public static int roadQuality(String type) { //function to check road state //for testing purposes, these checks are being separated //so they can proc independently during a roadtrip double rand = 0; switch (type) { case "WET": rand = Math.floor(Math.random()*10); if (rand == 1) {return 1;} else {return 0;} case "SURFACE": { rand = Math.floor(Math.random()*20); if (rand == 1) {return 1;} else {return 0;} } } return 1; } }