SHARE
TWEET

Untitled

a guest Dec 7th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Blok5;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class zad32_sklepik {
  7.  
  8.     public static void main(String[] args) {
  9.         Towar towar1 = new Towar(1, Kategoria.bulbulator, "Bulbulator", 10, 100);
  10.         Towar towar2 = new Towar(1, Kategoria.bulbulator, "Bulbulator xiaomi", 10, 50);
  11.  
  12.         Sklep.INSTANCE.Magazyn.add(towar1);
  13.         Sklep.INSTANCE.Magazyn.add(towar2);
  14.     }
  15.  
  16. }
  17.  
  18. class Sklep {
  19.     public static final Sklep INSTANCE = new Sklep();
  20.  
  21.     public List<Towar> Magazyn = new ArrayList<Towar>();
  22.  
  23. }
  24.  
  25. class Towar {
  26.  
  27.     private int nr;
  28.     private Kategoria kategoria;
  29.     private String nazwa;
  30.     private int ilosc;
  31.     private int cena_jedn;
  32.  
  33.     public Towar (int nr, Kategoria kategoria, String nazwa, int ilosc, int cena_jedn) {
  34.  
  35.         this.nr=nr;
  36.         this.kategoria=kategoria;
  37.         this.nazwa=nazwa;
  38.         this.ilosc=ilosc;
  39.         this.cena_jedn=cena_jedn;
  40.  
  41.     }
  42.  
  43.     public int getNr() {
  44.         return nr;
  45.     }
  46.  
  47.     public String getKategoria() {
  48.         return kategoria;
  49.     }
  50.  
  51.     public String getNazwa() {
  52.         return nazwa;
  53.     }
  54.  
  55.     public int getIlosc() {
  56.         return ilosc;
  57.     }
  58.  
  59.     public int getCena() {
  60.         return cena_jedn;
  61.     }
  62.  
  63.     public int getCenaLaczna() {
  64.         return cena_jedn*ilosc;
  65.     }
  66.  
  67. }
  68.  
  69. class Koszyk {
  70.     public static final Koszyk INSTANCE = new Koszyk();
  71.  
  72.     public List<Towar> Magazyn = new ArrayList<Towar>();
  73.  
  74. }
  75.  
  76. enum Kategoria {TV, Pralka, Koks, bulbulator}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top