Advertisement
Guest User

Untitled

a guest
Apr 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.96 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sport1;
  7. import sprzet.Pilka;
  8. import sprzet.PilkaDoSportu;
  9.  
  10. /**
  11.  *
  12.  * @author wykaj
  13.  */
  14. public class Boisko {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.    
  20.    public enum Materialy {
  21.         guma,
  22.         skora,
  23.         plastik,
  24.         szklo,
  25.     }
  26.     public static void main(String[] args) {
  27.         // TODO code application logic here
  28.         PilkaDoSportu pilka1 = new PilkaDoSportu(Materialy.guma , 10 , 10);
  29.         Pilka.aktualnaLiczbaPilek();
  30.         PilkaDoSportu pilka2 = new PilkaDoSportu(Materialy.guma , 10 , 10);
  31.         Pilka.aktualnaLiczbaPilek();
  32.        
  33.        System.out.println( pilka1.wysokoscOdbicia(10) );
  34.         pilka1.powiekszeniePromienia();
  35.         System.out.println( pilka1.wysokoscOdbicia(10) );
  36.  
  37.         System.out.println( pilka1.wysokoscOdbicia(10) );
  38.         pilka2.powiekszeniePromienia();
  39.         System.out.println( pilka1.wysokoscOdbicia(10) );
  40.  
  41.     }
  42.    
  43. }
  44. -----------------------------------------------------------------------
  45. /*
  46.  * To change this license header, choose License Headers in Project Properties.
  47.  * To change this template file, choose Tools | Templates
  48.  * and open the template in the editor.
  49.  */
  50. package sprzet;
  51. import java.util.Scanner;
  52. import sport1.Boisko;
  53. /**
  54.  *
  55.  * @author wykaj
  56.  */
  57. public class PilkaDoSportu extends Pilka{
  58.     float wspSprezystosci;
  59.    
  60.     public PilkaDoSportu ( Boisko.Materialy material , float wspSprezystosci, int promien)
  61.     {
  62.         super(promien);
  63.         this.wspSprezystosci = wspSprezystosci;
  64.        
  65.     }
  66.    
  67.       public float wysokoscOdbicia ( float wysokoscPoczatkowa)
  68.       {
  69.           return wysokoscPoczatkowa * wspSprezystosci *promien;
  70.       }
  71.      
  72.       public void powiekszeniePromienia()
  73.       {
  74.           Scanner x = new Scanner(System.in);
  75.           int liczba = x.nextInt();
  76.          
  77.          promien = promien + liczba;
  78.          
  79.          System.out.println("Promien wynosi teraz : " + promien);
  80.       }
  81.      
  82. }
  83. -------------------------------------------------------------------------------------
  84. /*
  85.  * To change this license header, choose License Headers in Project Properties.
  86.  * To change this template file, choose Tools | Templates
  87.  * and open the template in the editor.
  88.  */
  89. package sprzet;
  90.  
  91. /**
  92.  *
  93.  * @author wykaj
  94.  */
  95. public abstract class Pilka {
  96.     protected int promien;
  97.     private static int liczbaUtworzonychPilek = 0;
  98.    
  99.     public Pilka(int promien)
  100.     {
  101.         this.promien = promien;
  102.         liczbaUtworzonychPilek ++;;
  103.     }
  104.    
  105.     public abstract float wysokoscOdbicia ( float wysokoscPoczatkowa);
  106.    
  107.     public static void aktualnaLiczbaPilek ()
  108.     {
  109.         System.out.println("Aktualna liczba pilek wynosi : " +liczbaUtworzonychPilek);
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement