Advertisement
alicemiriel

Untitled

Mar 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. package sklep;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. public class Sklep {
  7.  
  8.     private Produkt produkt;
  9.     private Map<String, Produkt> asortyment;
  10.  
  11.  
  12.     public Sklep() {
  13.         asortyment = new HashMap<>();
  14.     }
  15.  
  16.     private void dodajDoAsortymentu(Produkt produkt) {
  17.         Produkt produkt = new Produkt("Mleko", "00000001", 2.5);
  18.         String daneProduktu = produkt.getKodKreskowy();
  19.         if (!asortyment.containsKey(daneProduktu){
  20.             asortyment = asortyment.putIfAbsent(produkt.getKodKreskowy(),Produkt produkt);
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement