Advertisement
Raleurs

LieuxExtremes

Dec 8th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. //traitementVol
  2. public static void statistique3(){
  3.         System.out.println("Les quatres extremes sont :" );
  4.         afficherParcours(vol.LieuxExtremes());
  5.     }
  6.  
  7. //Vol
  8.  
  9. public Coordonnees[] LieuxExtremes(){
  10.         long maxLong = Long.MIN_VALUE, minLong = Long.MAX_VALUE, maxLat = Long.MIN_VALUE, minLat = Long.MAX_VALUE, courantLat, courantLong;
  11.         int indiceEst = 0, indiceNord = 0, indiceOuest = 0, indiceSud = 0;
  12.         for (int i = 0; i < tableCoordonnees.length; i++) {
  13.             courantLat=tableCoordonnees[i].getLatitude();
  14.             courantLong = tableCoordonnees[i].getLongitude();
  15.            
  16.                 if(courantLat > maxLat){
  17.                     indiceNord = i;
  18.                     maxLat = courantLat ;
  19.                 }
  20.                 if (courantLat <= minLat) {
  21.                     indiceSud = i;
  22.                     minLat = courantLat;
  23.                 }
  24.                 if (courantLong >= maxLong) {
  25.                     indiceEst = i;
  26.                     maxLong = courantLat;  
  27.                 }
  28.                 if (courantLong <= minLong) {
  29.                     indiceOuest = i;
  30.                     minLong = courantLong; 
  31.                 }          
  32.         }
  33.         Coordonnees [] extremes ={tableCoordonnees[indiceNord], tableCoordonnees[indiceSud], tableCoordonnees[indiceEst], tableCoordonnees[indiceOuest]};
  34.         return extremes;
  35.        
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement