Skip to content

Commit

Permalink
Merge pull request #3 from nguyenj-c/ZooFinal
Browse files Browse the repository at this point in the history
Zoo final
  • Loading branch information
Khalil-Mohamed committed Dec 23, 2021
2 parents 3eb1dd7 + f4a66f5 commit c5d6671
Show file tree
Hide file tree
Showing 125 changed files with 9,308 additions and 3,297 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class Aigles extends Animaux implements Volants {

/**
* Constructeur d'aigles
* @param name
*
* @param name de l'aigle
*/
public Aigles(String name) {
super(name);
Expand All @@ -21,9 +22,9 @@ public Aigles(String name) {
*/
@Override
public void reproduire() {
if(this.isSexe() == false) {
if (!this.isSexe()) {
System.out.println("Je ponds un oeuf");
}else {
} else {
System.out.println("Je peux pas pondre car je suis un male");
}
}
Expand All @@ -38,9 +39,12 @@ public void deplacement() {

/**
* Espèce de l'animal
* @return string
*
* @return String
*/
@Override
public String getSpecies() {return "Aigle";}
public String getSpecies() {
return "Aigle";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @author Nguyen, Khalil
*
*/
package Animaux;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public final class AnimalRegistry {

private static final Map<Class<? extends Animaux>, List<Animaux>> ANIMAL_REGISTRY = new HashMap<>();

/**
* Ajoute l'animal au registre
*
* @param animal à enregistrer
*/
public static void registerAnimal(Animaux animal) {
if (animal == null)
return;

assertClassExists(animal.getClass());
ANIMAL_REGISTRY.get(animal.getClass()).add(animal);
}

/**
* Enlève l'animal du registre
*
* @param animal à supprimer du registre
*/
public static void unregisterAnimal(Animaux animal) {
if (animal != null && ANIMAL_REGISTRY.containsKey(animal.getClass())) {
ANIMAL_REGISTRY.get(animal.getClass()).remove(animal);
}
}

private static void assertClassExists(Class<? extends Animaux> especes) {
ANIMAL_REGISTRY.putIfAbsent(especes, new ArrayList<>());
}

/**
* Renvoie la liste d'animaux par classe
*
* @param especes type d'animaux
* @return List
*/
public static List<Animaux> getRegisteredAnimalsByClass(Class<? extends Animaux> especes) {
if (especes != null && ANIMAL_REGISTRY.containsKey(especes)) {
return ANIMAL_REGISTRY.get(especes);
}
return null;
}
}
Loading

0 comments on commit c5d6671

Please sign in to comment.