Talar97

Lab07_Czolgi

Dec 1st, 2017
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. package com.Talar;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Czolgi {
  6.     public String typ;
  7.     public String nazwa;
  8.     protected double cena;
  9.     protected double kaliber;
  10.     protected double pancerz_przod;
  11.     public double skutecznosc = 0;
  12.  
  13.     public Czolgi(String typ, String nazwa, int cena, double kaliber, double pancerz){
  14.         this.typ = typ;
  15.         this.nazwa = nazwa;
  16.         this.cena = cena;
  17.         this.kaliber = kaliber;
  18.         this.pancerz_przod = pancerz;
  19.  
  20.         this.wyliczSkutecznosc();
  21.     }
  22.  
  23.     public Czolgi(){
  24.         this.ustawWartosci();
  25.         this.wyliczSkutecznosc();
  26.     }
  27.  
  28.     public void ustawWartosci(){
  29.         Scanner inp = new Scanner(System.in);
  30.         Scanner inp1 = new Scanner(System.in);
  31.         Scanner inp2 = new Scanner(System.in);
  32.  
  33.         System.out.print("Wprowadź wartości: \n");
  34.         System.out.print("\tNazwa: ");                this.nazwa = inp.nextLine();
  35.         System.out.print("\tTyp: ");                  this.typ = inp.nextLine();
  36.         System.out.print("\tCena: ");                 this.cena = inp2.nextDouble();
  37.         System.out.print("\tKaliber działa: ");       this.kaliber = inp2.nextDouble();
  38.         System.out.print("\tPancerz: ");              this.pancerz_przod = inp2.nextDouble();
  39.     }
  40.  
  41.     public void wyliczSkutecznosc(){
  42.         this.skutecznosc = this.pancerz_przod * kaliber;
  43.     }
  44.  
  45.     public void wyswietlDane(){
  46.         System.out.print("\nNazwa: " + nazwa);
  47.         System.out.print("\n\t*Typ: "+ typ);
  48.         System.out.print("\n\t*Cena: "+ cena + " kredytów");
  49.         System.out.print("\n\t*Kaliber działa: " + kaliber + " mm");
  50.         System.out.print("\n\t*Pancerz: "+ pancerz_przod + " mm");
  51.         System.out.print("\n\t*Skuteczność bojowa: "+ skutecznosc);
  52.     }
  53. }
Add Comment
Please, Sign In to add comment