package intecbrussel.be.Vaccination;_x000D_
_x000D_
import java.util.*;_x000D_
import java.util.stream.Collectors;_x000D_
_x000D_
public class AnimalShelter {_x000D_
    private List<Animal> animals;_x000D_
    private int animalId;_x000D_
_x000D_
    public AnimalShelter() {_x000D_
        this.animals = new ArrayList<>();_x000D_
        this.animalId = 1;_x000D_
    }_x000D_
_x000D_
    public List<Animal> getAnimals() {_x000D_
        return animals;_x000D_
    }_x000D_
_x000D_
    public void setAnimals(List<Animal> animals) {_x000D_
        this.animals = animals;_x000D_
    }_x000D_
_x000D_
    public int getAnimalId() {_x000D_
        return animalId;_x000D_
    }_x000D_
_x000D_
    public void setAnimalId(int animalId) {_x000D_
        this.animalId = animalId;_x000D_
    }_x000D_
//1_x000D_
    public void printAnimals(){_x000D_
        for (Animal animal : animals){_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }_x000D_
    }_x000D_
    // sorteert de dieren volgens hun natuurlijke volgorde, dit is volgens hun animalNumber._x000D_
    //2_x000D_
    public void sortAnimals(){_x000D_
        animals.sort(Comparator.comparing(Animal::getAnimalNumber));_x000D_
    }_x000D_
    //sorteert de dieren op naam_x000D_
    //3_x000D_
    public void sortAnimalsByName(){_x000D_
        animals.sort(Comparator.comparing(Animal::getName));_x000D_
    }_x000D_
    // sorteert de dieren op leeftijd_x000D_
    //4_x000D_
    public void sortAnimalsByAge(){_x000D_
        animals.sort(Comparator.comparing(Animal::getAge));_x000D_
    }_x000D_
    //print alle dieren af die niet gevaccineert zijn voor een opgegeven ziekte_x000D_
    //5_x000D_
    public void printAnimalsNotVaccinated(Disease disease){_x000D_
        List<Animal> notVaccinated = animals.stream().filter(animal -> animal.getIsVaccinated().getOrDefault(disease, false)).collect(Collectors.toList());_x000D_
        for (Animal animal : notVaccinated){_x000D_
            System.out.println(animal.getName()+" is not vaccinated "+disease.name());_x000D_
        }_x000D_
    }_x000D_
    //zoek dier op dierennummer_x000D_
    //6_x000D_
    public Animal findAnimal(int animalNumber) {_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getAnimalNumber() == animalNumber){_x000D_
                return animal;_x000D_
            }_x000D_
        }_x000D_
        return null;_x000D_
      // return animals.stream().filter(animal -> animal.getAnimalNumber()==animalNumber).findFirst();_x000D_
        }_x000D_
_x000D_
    //zoek dier op dierennaam_x000D_
    //7_x000D_
    public Optional<Animal> findAnimal(String name){_x000D_
        return animals.stream().filter(animal -> animal.getName().equalsIgnoreCase(name)).findFirst();_x000D_
_x000D_
    }_x000D_
    // behandel opgegeven dier_x000D_
    //8_x000D_
    public void treatAnimal(int animalNumber){_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getAnimalNumber()==animalNumber){_x000D_
                System.out.println("treat animal by number: "+animal.getAnimalNumber()+animal.getIsVaccinated());_x000D_
_x000D_
            }_x000D_
        }_x000D_
_x000D_
        //System.out.println("animal with number "+animalNumber+"not found");_x000D_
       /* animals.stream()_x000D_
                .sorted(Comparator.comparingInt(Animal::getAnimalNumber))_x000D_
                .forEach(animal -> System.out.println(_x000D_
                        "Animal number: "+animal.getAnimalNumber()+_x000D_
                                "| name: "+animal.getName()+_x000D_
                                "| age: "+animal.getAge()+_x000D_
                                "| is clean? "+animal.getIsVaccinated()_x000D_
                ));///////////////////////////////////////////////////////////////////////////////////////////////////////_x000D_
        /*Optional<Animal> optionalAnimal = findAnimal(animalNumber);_x000D_
        if (optionalAnimal.isPresent()){_x000D_
            Animal animal = optionalAnimal.get();_x000D_
            animal.treatAnimal();_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }else {_x000D_
            System.out.println("animal met number "+animalNumber+"not found");_x000D_
        }*/_x000D_
    }_x000D_
    //behandel opgegeven dier_x000D_
    //9_x000D_
    public void treatAnimal(String name){_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getName()==name){_x000D_
                System.out.println("treat animal by name: "+animal.getName()+animal.getIsVaccinated());_x000D_
_x000D_
            }_x000D_
        }_x000D_
        /*animals.stream()_x000D_
                .sorted(Comparator.comparing(Animal::getName))_x000D_
                .forEach(animal -> System.out.println(_x000D_
                        "name: "+animal.getName()+_x000D_
                                "| animal number: "+animal.getAnimalNumber()+_x000D_
                                "| age: "+animal.getAge()+_x000D_
                                "| is clean? "+animal.getIsVaccinated()_x000D_
                ));/////////////////////////////////////////////////////////////////////////////////////////////////////_x000D_
       /* Optional<Animal> optionalAnimal = findAnimal(name);_x000D_
        if (optionalAnimal.isPresent()){_x000D_
            Animal animal = optionalAnimal.get();_x000D_
            animal.treatAnimal();_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }else {_x000D_
            System.out.println("animal met name "+name+ "not found");_x000D_
        }*/_x000D_
_x000D_
    }_x000D_
    //behandel alle dieren_x000D_
    //10_x000D_
    public void treatAllAnimals(){_x000D_
        for (Animal animal : animals){_x000D_
            animal.treatAnimal();_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }_x000D_
_x000D_
    }_x000D_
    //geef het oudste dier terug_x000D_
    //11_x000D_
    public Animal findOldestAnimal() throws NoSuchElementException {_x000D_
        if (animals.isEmpty()) {_x000D_
            throw new NoSuchElementException("No animal found in this list");_x000D_
        }_x000D_
            Animal oldestAnimal = animals.get(0);_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getAge() > oldestAnimal.getAge()){_x000D_
                oldestAnimal = animal;_x000D_
                //System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
            }_x000D_
        }_x000D_
        return oldestAnimal;_x000D_
_x000D_
    }_x000D_
_x000D_
    // geef het aantal dieren terug_x000D_
    //12_x000D_
    public int countAnimals(){_x000D_
        if (animals != null){_x000D_
            return animals.size();_x000D_
        }else {_x000D_
            return 0;_x000D_
        }_x000D_
    }_x000D_
_x000D_
    //voeg een dier toe aan de lijst van animals_x000D_
    //13_x000D_
    public void addAnimal(Animal animal) throws IllegalArgumentException{_x000D_
        if (animal != null){_x000D_
            animal.setAnimalNumber(animalId);//toewijzen de nummer animal_x000D_
            animals.add(animal);//add de animal to de list_x000D_
            animalId++;//verhoog de animal id_x000D_
        }else {_x000D_
            throw new IllegalArgumentException("Can not add null animal to de list");_x000D_
        }_x000D_
_x000D_
    }_x000D_
_x000D_
}_x000D_

//toewijzen de nummer animal_x000D_
package intecbrussel.be.Vaccination;_x000D_
_x000D_
import java.util.*;_x000D_
import java.util.stream.Collectors;_x000D_
_x000D_
public class AnimalShelter {_x000D_
    private List<Animal> animals;_x000D_
    private int animalId;_x000D_
_x000D_
    public AnimalShelter() {_x000D_
        this.animals = new ArrayList<>();_x000D_
        this.animalId = 1;_x000D_
    }_x000D_
_x000D_
    public List<Animal> getAnimals() {_x000D_
        return animals;_x000D_
    }_x000D_
_x000D_
    public void setAnimals(List<Animal> animals) {_x000D_
        this.animals = animals;_x000D_
    }_x000D_
_x000D_
    public int getAnimalId() {_x000D_
        return animalId;_x000D_
    }_x000D_
_x000D_
    public void setAnimalId(int animalId) {_x000D_
        this.animalId = animalId;_x000D_
    }_x000D_
//1_x000D_
    public void printAnimals(){_x000D_
        for (Animal animal : animals){_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }_x000D_
    }_x000D_
    // sorteert de dieren volgens hun natuurlijke volgorde, dit is volgens hun animalNumber._x000D_
    //2_x000D_
    public void sortAnimals(){_x000D_
        animals.sort(Comparator.comparing(Animal::getAnimalNumber));_x000D_
    }_x000D_
    //sorteert de dieren op naam_x000D_
    //3_x000D_
    public void sortAnimalsByName(){_x000D_
        animals.sort(Comparator.comparing(Animal::getName));_x000D_
    }_x000D_
    // sorteert de dieren op leeftijd_x000D_
    //4_x000D_
    public void sortAnimalsByAge(){_x000D_
        animals.sort(Comparator.comparing(Animal::getAge));_x000D_
    }_x000D_
    //print alle dieren af die niet gevaccineert zijn voor een opgegeven ziekte_x000D_
    //5_x000D_
    public void printAnimalsNotVaccinated(Disease disease){_x000D_
        List<Animal> notVaccinated = animals.stream().filter(animal -> animal.getIsVaccinated().getOrDefault(disease, false)).collect(Collectors.toList());_x000D_
        for (Animal animal : notVaccinated){_x000D_
            System.out.println(animal.getName()+" is not vaccinated "+disease.name());_x000D_
        }_x000D_
    }_x000D_
    //zoek dier op dierennummer_x000D_
    //6_x000D_
    public Animal findAnimal(int animalNumber) {_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getAnimalNumber() == animalNumber){_x000D_
                return animal;_x000D_
            }_x000D_
        }_x000D_
        return null;_x000D_
      // return animals.stream().filter(animal -> animal.getAnimalNumber()==animalNumber).findFirst();_x000D_
        }_x000D_
_x000D_
    //zoek dier op dierennaam_x000D_
    //7_x000D_
    public Optional<Animal> findAnimal(String name){_x000D_
        return animals.stream().filter(animal -> animal.getName().equalsIgnoreCase(name)).findFirst();_x000D_
_x000D_
    }_x000D_
    // behandel opgegeven dier_x000D_
    //8_x000D_
    public void treatAnimal(int animalNumber){_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getAnimalNumber()==animalNumber){_x000D_
                System.out.println("treat animal by number: "+animal.getAnimalNumber()+animal.getIsVaccinated());_x000D_
_x000D_
            }_x000D_
        }_x000D_
_x000D_
        //System.out.println("animal with number "+animalNumber+"not found");_x000D_
       /* animals.stream()_x000D_
                .sorted(Comparator.comparingInt(Animal::getAnimalNumber))_x000D_
                .forEach(animal -> System.out.println(_x000D_
                        "Animal number: "+animal.getAnimalNumber()+_x000D_
                                "| name: "+animal.getName()+_x000D_
                                "| age: "+animal.getAge()+_x000D_
                                "| is clean? "+animal.getIsVaccinated()_x000D_
                ));///////////////////////////////////////////////////////////////////////////////////////////////////////_x000D_
        /*Optional<Animal> optionalAnimal = findAnimal(animalNumber);_x000D_
        if (optionalAnimal.isPresent()){_x000D_
            Animal animal = optionalAnimal.get();_x000D_
            animal.treatAnimal();_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }else {_x000D_
            System.out.println("animal met number "+animalNumber+"not found");_x000D_
        }*/_x000D_
    }_x000D_
    //behandel opgegeven dier_x000D_
    //9_x000D_
    public void treatAnimal(String name){_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getName()==name){_x000D_
                System.out.println("treat animal by name: "+animal.getName()+animal.getIsVaccinated());_x000D_
_x000D_
            }_x000D_
        }_x000D_
        /*animals.stream()_x000D_
                .sorted(Comparator.comparing(Animal::getName))_x000D_
                .forEach(animal -> System.out.println(_x000D_
                        "name: "+animal.getName()+_x000D_
                                "| animal number: "+animal.getAnimalNumber()+_x000D_
                                "| age: "+animal.getAge()+_x000D_
                                "| is clean? "+animal.getIsVaccinated()_x000D_
                ));/////////////////////////////////////////////////////////////////////////////////////////////////////_x000D_
       /* Optional<Animal> optionalAnimal = findAnimal(name);_x000D_
        if (optionalAnimal.isPresent()){_x000D_
            Animal animal = optionalAnimal.get();_x000D_
            animal.treatAnimal();_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }else {_x000D_
            System.out.println("animal met name "+name+ "not found");_x000D_
        }*/_x000D_
_x000D_
    }_x000D_
    //behandel alle dieren_x000D_
    //10_x000D_
    public void treatAllAnimals(){_x000D_
        for (Animal animal : animals){_x000D_
            animal.treatAnimal();_x000D_
            System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
        }_x000D_
_x000D_
    }_x000D_
    //geef het oudste dier terug_x000D_
    //11_x000D_
    public Animal findOldestAnimal() throws NoSuchElementException {_x000D_
        if (animals.isEmpty()) {_x000D_
            throw new NoSuchElementException("No animal found in this list");_x000D_
        }_x000D_
            Animal oldestAnimal = animals.get(0);_x000D_
        for (Animal animal : animals){_x000D_
            if (animal.getAge() > oldestAnimal.getAge()){_x000D_
                oldestAnimal = animal;_x000D_
                //System.out.println("Name: "+animal.getName()+" | "+" Age: "+animal.getAge()+" | "+" Animal number: "+animal.getAnimalNumber()+" | "+" is clean ? "+animal.getIsVaccinated());_x000D_
            }_x000D_
        }_x000D_
        return oldestAnimal;_x000D_
_x000D_
    }_x000D_
_x000D_
    // geef het aantal dieren terug_x000D_
    //12_x000D_
    public int countAnimals(){_x000D_
        if (animals != null){_x000D_
            return animals.size();_x000D_
        }else {_x000D_
            return 0;_x000D_
        }_x000D_
    }_x000D_
_x000D_
    //voeg een dier toe aan de lijst van animals_x000D_
    //13_x000D_
    public void addAnimal(Animal animal) throws IllegalArgumentException{_x000D_
        if (animal != null){_x000D_
            animal.setAnimalNumber(animalId);//toewijzen de<SUF>
            animals.add(animal);//add de animal to de list_x000D_
            animalId++;//verhoog de animal id_x000D_
        }else {_x000D_
            throw new IllegalArgumentException("Can not add null animal to de list");_x000D_
        }_x000D_
_x000D_
    }_x000D_
_x000D_
}_x000D_
