Falu

Untitled

Feb 1st, 2018
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. class WynikiSerii extends Seria{
  2.  
  3.     public WynikiSerii(int lbZawodnikow) {
  4.         super(lbZawodnikow);
  5.     }
  6.  
  7.     private double skoki[][] = null;
  8.    
  9.     public int najlepszyZawidnik() {
  10.         double MAX = -Double.MAX_VALUE, suma;
  11.         int nrNajSkoczka = 0;
  12.        
  13.         for(int i = 0; i < skoki.length; ++i) {
  14.             suma = 0;
  15.             for(int j = 0; j < skoki[i].length; ++i) {
  16.                 suma+=pobierz ( i, j);
  17.                 if( suma > MAX) {
  18.                     MAX = skoki[i][j];
  19.                     nrNajSkoczka = i;
  20.                 }
  21.                 }
  22.             }
  23.         return nrNajSkoczka;
  24.     }
  25.    
  26. }
  27.  
  28. public class Seria{
  29.    
  30.     private double skoki[][] = null;
  31.    
  32.     public Seria(int lbZawodnikow){
  33.        
  34.         skoki= new double [lbZawodnikow][2];
  35.        
  36.         for(int i = 0; i < skoki.length; ++i) {
  37.             for(int j = 0; j < skoki[i].length; ++i) {
  38.                 skoki[i][j] = 0;
  39.             }
  40.         }
  41.     }
  42.    
  43.     public boolean wstaw( int nrSkoczka, int nrSkoku, double odleglosc) {
  44.        
  45.         if((( (nrSkoczka-1) > skoki.length) || (nrSkoczka-1) < 0) && ((nrSkoku-1) < 0 || (nrSkoku-1) > skoki[nrSkoczka].length) ){
  46.             return false;
  47.         }
  48.         else {
  49.             skoki[nrSkoczka][nrSkoku] = odleglosc;     
  50.             return true;
  51.         }
  52.     }
  53.    
  54.     public double pobierz ( int nrSkoczka, int nrSkoku) {
  55.        
  56.         double wynik = 0;
  57.        
  58.         if((((nrSkoczka-1)>skoki.length) || (nrSkoczka-1) < 0) && ((nrSkoku-1)<0 || (nrSkoku-1)>skoki[nrSkoczka].length) ){
  59.             wynik = -1;
  60.         }
  61.        
  62.         else
  63.             wynik = skoki[nrSkoczka][nrSkoku];
  64.        
  65.         return wynik;
  66.     }
  67.    
  68. }
Add Comment
Please, Sign In to add comment