Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AllergyRegister {
- private static AllergyRegister instance;
- private Map<Integer, Allergy> allergies;
- public static AllergyRegister getInstance(){
- if(instance == null)
- instance = new AllergyRegister();
- return instance;
- }
- //constructor private houden
- private AllergyRegister(){
- this.allergies = new TreeMap<>();
- }
- public void Register(Allergy allergy){
- this.allergies.put(allergy.getId(), allergy);
- }
- public Allergy getById(int id){
- return this.allergies.containsKey(id) ? this.allergies.get(id) : null;
- }
- public Map<Integer, Allergy> getAllAllergies(){
- return this.allergies;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement