View difference between Paste ID: eGrhgbeY and B596Zdc2
SHOW: | | - or go back to the newest paste.
1
public class AllergyRegister {
2
3
    private static AllergyRegister instance;
4
    private Map<Integer, Allergy> allergies;
5
6
    public static AllergyRegister getInstance(){
7
        if(instance == null)
8
            instance = new AllergyRegister();
9
        return instance;
10
    }
11
12
    private AllergyRegister(){
13-
    //constructor private houden
13+
14
    }
15
16
    public void Register(Allergy allergy){
17
        this.allergies.put(allergy.getId(), allergy);
18
    }
19
20
    public Allergy getByProductAllergyID(int prodAllergyID){
21
        for(Allergy allergy : allergies)
22-
    public Allergy getById(int id){
22+
            if(allergy.getProductAllergyID() == prodAllergyID)
23-
        return this.allergies.containsKey(id) ? this.allergies.get(id) : null;
23+
                return allergy;
24
        return null;
25-
    
25+
26
27
    public Map<Integer, Allergy> getAllAllergies(){
28
        return  this.allergies;
29
    }
30
31
}