Advertisement
Guest User

Untitled

a guest
May 4th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1.  
  2. package kolokwium.sport;
  3.  
  4. /**
  5.  *
  6.  * @author Robert
  7.  */
  8. public class Biegi extends Sport {
  9.  
  10.     Double dystans;
  11.     String jednostka;
  12.  
  13.     public double odczyt_dystans(double dystans) {
  14.         this.dystans = dystans;
  15.         return dystans;
  16.     }
  17.  
  18.     Biegi(double dystans) {
  19.         super("Biegi", "Indywidualne");
  20.         this.dystans=dystans;
  21.     }
  22.  
  23.     Biegi(double dystans, String jednostka) {
  24.         super("Biegi", "Indywidualne");
  25.          this.dystans=dystans;
  26.          this.jednostka=jednostka;
  27.     }
  28.  
  29.     public Double getDystans() {
  30.         return dystans;
  31.     }
  32.  
  33.     public String getJednostka() {
  34.         return jednostka;
  35.     }
  36.    
  37.     public String toString (double dystans, String jednostka, String typSportu, String nazwaDyscypliny){
  38.         String tekst="";
  39.     if(jednostka.equals("km"))
  40.     {
  41.      tekst =  "Sport o nazwie:"+this.nazwaDyscypliny+"type: "+this.typSportu+(String.format("%.3f", dystans))+jednostka;
  42.     }
  43.     if(jednostka.equals("m"))
  44.     {
  45.     tekst =  "Sport o nazwie:"+this.nazwaDyscypliny+"type: "+this.typSportu+ dystans+jednostka;
  46.     }
  47.     return tekst;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement