Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sport1;
- import sprzet.Pilka;
- import sprzet.PilkaDoSportu;
- /**
- *
- * @author wykaj
- */
- public class Boisko {
- /**
- * @param args the command line arguments
- */
- public enum Materialy {
- guma,
- skora,
- plastik,
- szklo,
- }
- public static void main(String[] args) {
- // TODO code application logic here
- PilkaDoSportu pilka1 = new PilkaDoSportu(Materialy.guma , 10 , 10);
- Pilka.aktualnaLiczbaPilek();
- PilkaDoSportu pilka2 = new PilkaDoSportu(Materialy.guma , 10 , 10);
- Pilka.aktualnaLiczbaPilek();
- System.out.println( pilka1.wysokoscOdbicia(10) );
- pilka1.powiekszeniePromienia();
- System.out.println( pilka1.wysokoscOdbicia(10) );
- System.out.println( pilka1.wysokoscOdbicia(10) );
- pilka2.powiekszeniePromienia();
- System.out.println( pilka1.wysokoscOdbicia(10) );
- }
- }
- -----------------------------------------------------------------------
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sprzet;
- import java.util.Scanner;
- import sport1.Boisko;
- /**
- *
- * @author wykaj
- */
- public class PilkaDoSportu extends Pilka{
- float wspSprezystosci;
- public PilkaDoSportu ( Boisko.Materialy material , float wspSprezystosci, int promien)
- {
- super(promien);
- this.wspSprezystosci = wspSprezystosci;
- }
- public float wysokoscOdbicia ( float wysokoscPoczatkowa)
- {
- return wysokoscPoczatkowa * wspSprezystosci *promien;
- }
- public void powiekszeniePromienia()
- {
- Scanner x = new Scanner(System.in);
- int liczba = x.nextInt();
- promien = promien + liczba;
- System.out.println("Promien wynosi teraz : " + promien);
- }
- }
- -------------------------------------------------------------------------------------
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sprzet;
- /**
- *
- * @author wykaj
- */
- public abstract class Pilka {
- protected int promien;
- private static int liczbaUtworzonychPilek = 0;
- public Pilka(int promien)
- {
- this.promien = promien;
- liczbaUtworzonychPilek ++;;
- }
- public abstract float wysokoscOdbicia ( float wysokoscPoczatkowa);
- public static void aktualnaLiczbaPilek ()
- {
- System.out.println("Aktualna liczba pilek wynosi : " +liczbaUtworzonychPilek);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement