Created
April 13, 2013 16:26
-
-
Save samklr/5379076 to your computer and use it in GitHub Desktop.
DevKings FastCode .....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class Challenge2 { | |
| List <Arret> arretList = new ArrayList<Arret>(); | |
| public static void main(String[] args){ | |
| System.out.println(" StopArea:ABDU".substring(10)); | |
| String out = " StopArea:ABDU, Abel Durand,,47.22019661,-1.60337553,,,1,"; | |
| for (String st : out.split(",")){ | |
| System.out.println(st); | |
| } | |
| } | |
| public void parseStdInput(InputStreamReader in){ | |
| InputStreamReader isr = new InputStreamReader(System.in); | |
| BufferedReader br = new BufferedReader(isr); | |
| try { | |
| //Read the two stops | |
| String depart = br.readLine().substring(10); //read departure stop | |
| String arrivee = br.readLine().substring(10); //read arival stop | |
| //Read the next number of stops in csv format | |
| int nbArret = Integer.parseInt(br.readLine()); | |
| //Read the next nbArret in the file and put them in List<Arret> | |
| for (int i = 0; i<=nbArret-1; i++){ | |
| String[] lineArret = br.readLine().split(","); | |
| Arret arret = new Arret(lineArret[0].substring(10), | |
| lineArret[1], | |
| Integer.parseInt(lineArret[4]), | |
| Integer.parseInt(lineArret[3]) | |
| ); | |
| arretList.add(arret); | |
| } | |
| //Read the number of connection between stops | |
| int nbLinks = Integer.parseInt(br.readLine()); | |
| //Read all the connections between the stations | |
| for (int k=0; k< nbLinks ; k++){ | |
| } | |
| } catch (IOException e) { | |
| // TODO Auto-generated catch block | |
| e.printStackTrace(); | |
| } | |
| } | |
| public double distance(Arret a, Arret b){ | |
| double x = (b.getLongitude()-a.getLongitude())*Math.cos((a.getLatitude()+b.getLatitude())/2); | |
| double y = b.getLatitude() - a.getLatitude(); | |
| return Math.sqrt(x*x + y*y) * 6371; | |
| } | |
| } | |
| class Arret{ | |
| String id; | |
| String fullName; | |
| double longitude; | |
| double latitude; | |
| public Arret(String id, String fullName, double longitude, | |
| double latitude) { | |
| super(); | |
| this.id = id; | |
| this.fullName = fullName; | |
| this.longitude = longitude; | |
| this.latitude = latitude; | |
| } | |
| public String getId() { | |
| return id; | |
| } | |
| public void setId(String id) { | |
| this.id = id; | |
| } | |
| public String getFullName() { | |
| return fullName; | |
| } | |
| public void setFullName(String fullName) { | |
| this.fullName = fullName; | |
| } | |
| public double getLongitude() { | |
| return longitude; | |
| } | |
| public void setLongitude(double longitude) { | |
| this.longitude = longitude; | |
| } | |
| public double getLatitude() { | |
| return latitude; | |
| } | |
| public void setLatitude(double latitude) { | |
| this.latitude = latitude; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment