Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pernica;
- import java.util.HashMap;
- public class Pernica {
- private HashMap<String,Bojica> bojice;
- private int raspolozivoMesto;
- public Pernica() {
- bojice=new HashMap<String,Bojica>();
- this.raspolozivoMesto=5;
- }
- public boolean dodaj(Bojica b) {
- if(bojice.containsKey(b.getSerijski_broj())) return false;
- if(this.raspolozivoMesto>bojice.size()) {
- bojice.put(b.getSerijski_broj(),b);
- return true;
- }else return false;
- }
- public int prebroj(double prosledjena_cena) {
- int brojac=0;
- for(Bojica bojica : bojice.values()) { //obavezno values
- if(bojica.getCena()>prosledjena_cena) {
- brojac++;
- }
- }
- return brojac;
- }
- @Override
- public String toString() {
- if(this.bojice.isEmpty()) {
- System.out.println("Nema bojica peratonica");
- return "";
- }
- return "Pernica [bojice=" + bojice + ", raspolozivoMesto=" + raspolozivoMesto + "]";
- }
- }
Add Comment
Please, Sign In to add comment