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 int 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, this function will return 0 to signal no hazard detected //for testing purposes, this function will roll a 1/100 chance of detecting a hazard double detection = Math.floor(Math.random()*100); if (detection == 1) { return 1; } else { return 0; } } public int 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 1; } else { return 0; } } }