diff --git a/README.md b/README.md
index de9867a6623390895104030b1819a296050afb69..e2023e01e48e05e2aa9e37a173cb0a20be1cd8d3 100755
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Projet *Standard* (*Remplacer par numéro ou sujet du TP*) [![pipeline status](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/badges/master/pipeline.svg)](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/commits/master) [![coverage report](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/badges/master/coverage.svg)](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/commits/master)
+# Projet *Integration M1* [![pipeline status](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/badges/master/pipeline.svg)](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/commits/master) [![coverage report](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/badges/master/coverage.svg)](https://www-apps.univ-lehavre.fr/forge/pigne/projet-standard/commits/master)
- Année : **M1 iWOCS**
- Matière: *matière*
@@ -8,13 +8,15 @@
|Nom|Prénom|
|--|--|
-*Nom 1er auteur* | *Prénom 1er auteur*|
-*Nom 2eme auteur* | *Prénom 2eme auteur*|
+
+*ANDRIAMAHERISOA* | *NOMENJANAHARY MAHANDRISOA*|
## User Story
-- *Quels sont les fonctionnalités apportées par ce projet ?*
-- *A remplacer avec la description de votre projet.*
+- *Réalisation d'un simple modèle objet en Java qui permet de gérer un carnet d’adresses.*
+ Un carnet d’adresses est constitué d’entrées qui peuvent représenter des personnes ou des sociétés. Les informations et la présentation sont différentes s’il s’agis d’une personne ou d’une société.
+
+
## Configuration du projet
@@ -22,17 +24,9 @@ Pour obtenir les informations de couverture de code des tests dans la forge, il
Il faut également mettre à jour le nom du projet dans le fichier de configuration `pom.xml` dans la section ``.
-## Projet de base
-
-Ce projet est une base pour la réalisation de TP et projets dans différentes matières en informatique.
-
-Ses principales fonctionnalités sont :
-
-- Gestion de la compilation et des dépendances avec Maven (on peut utiliser [Maven Wrapper](https://github.com/takari/maven-wrapper) et la commande `mvnw` pour s'assurer de la compatibilité)
-- Framework de tests configuré pour tester les fonctionnalités du projet avec JUnit (voir les exemple dans `src/test/...`).
-- Exécution des tests avec maven `./mvnw test`
-- Intégration continue avec GitLab (voir fichier `.gitlab-ci.yaml`)
+## Projet
+Ce projet a été forké depuis le projet de base pour la réalisation de TP et projets dans différentes matières en informatique.
## Utilisation
diff --git a/src/main/java/fr/univlehavre/entree/Entree.java b/src/main/java/fr/univlehavre/entree/Entree.java
new file mode 100644
index 0000000000000000000000000000000000000000..5d47425f68d62ab96c4d0680d3616289a37fea37
--- /dev/null
+++ b/src/main/java/fr/univlehavre/entree/Entree.java
@@ -0,0 +1,6 @@
+package fr.univlehavre.entree;
+
+public interface Entree {
+ public String toString(Presentation presentation, Sens sens);
+ public Boolean recherche(String text);
+}
diff --git a/src/main/java/fr/univlehavre/entree/Genre.java b/src/main/java/fr/univlehavre/entree/Genre.java
new file mode 100644
index 0000000000000000000000000000000000000000..d6943ebe29c7b2c4b59abb101d8cbc6c8bb3ac9e
--- /dev/null
+++ b/src/main/java/fr/univlehavre/entree/Genre.java
@@ -0,0 +1,6 @@
+package fr.univlehavre.entree;
+
+public enum Genre {
+ HOMME,
+ FEMME
+}
diff --git a/src/main/java/fr/univlehavre/entree/Personne.java b/src/main/java/fr/univlehavre/entree/Personne.java
new file mode 100644
index 0000000000000000000000000000000000000000..42bedbca9143fb67a403636685c85ff585bf0329
--- /dev/null
+++ b/src/main/java/fr/univlehavre/entree/Personne.java
@@ -0,0 +1,91 @@
+package fr.univlehavre.entree;
+
+import java.util.Arrays;
+
+public class Personne implements Entree {
+ private String nom;
+ private String[] prenoms;
+ private Genre genre;
+ private Personne conjoint;
+ private Societe societe;
+ private String fonction;
+
+ public Personne(String nom, String[] prenoms, Genre genre, Personne conjoint, Societe societe, String fonction) {
+ this.nom = nom;
+ this.prenoms = prenoms;
+ this.genre = genre;
+ this.conjoint = conjoint;
+ this.societe = societe;
+ this.fonction = fonction;
+ }
+
+ public String getNom() {
+ return nom;
+ }
+
+ public String[] getPrenoms() {
+ return prenoms;
+ }
+
+ public Genre getGenre() {
+ return genre;
+ }
+
+ public Personne getConjoint() {
+ return conjoint;
+ }
+
+ public Societe getSociete() {
+ return societe;
+ }
+
+ public String getFonction() {
+ return fonction;
+ }
+
+ @Override
+ public String toString(Presentation presentation, Sens sens) {
+ String result = null;
+ switch (presentation) {
+ case COMPLET:
+ result = String.format(this.formatGenre() + "\n" + "-Société: " + this.societe + "\n" + "-Fonction: " + this.fonction);
+ break;
+ case ABREGE:
+ result = sens == Sens.NOM_PRENOMS ? this.nom + " " + initiales(this.prenoms) : initiales(this.prenoms) + " " + this.nom;
+ break;
+ case SIMPLE:
+ int len = this.prenoms.length;
+ String[] prenoms = Arrays.copyOfRange(this.prenoms, 1, len - 1);
+ result = this.formatGenre() + " " + initiales(prenoms) + " (" + this.societe.getNom() + ")";
+ break;
+ }
+ return result;
+ }
+
+ @Override
+ public Boolean recherche(String text) {
+ return null;
+ }
+
+ private String initiales(String[] prenoms) {
+ String result = "";
+ for (String prenom : prenoms) {
+ result.concat(prenom + ". ");
+ }
+ return result;
+ }
+
+ private String formatGenre() {
+ String genre = null;
+ switch (this.genre) {
+ case HOMME:
+ genre = "M.";
+ break;
+ case FEMME:
+ genre = "Mme";
+ break;
+ }
+ return genre;
+ }
+
+}
diff --git a/src/main/java/fr/univlehavre/entree/Presentation.java b/src/main/java/fr/univlehavre/entree/Presentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..8754f1afc6730bbe5005232f37f29db328a3f55e
--- /dev/null
+++ b/src/main/java/fr/univlehavre/entree/Presentation.java
@@ -0,0 +1,7 @@
+package fr.univlehavre.entree;
+
+public enum Presentation {
+ ABREGE,
+ SIMPLE,
+ COMPLET
+}
diff --git a/src/main/java/fr/univlehavre/entree/Sens.java b/src/main/java/fr/univlehavre/entree/Sens.java
new file mode 100644
index 0000000000000000000000000000000000000000..7913777c00cb87ba5dbd093388328624e4caa594
--- /dev/null
+++ b/src/main/java/fr/univlehavre/entree/Sens.java
@@ -0,0 +1,6 @@
+package fr.univlehavre.entree;
+
+public enum Sens {
+ NOM_PRENOMS,
+ PRENOMS_NOM
+}
diff --git a/src/test/java/fr/univlehavre/entree/PersonneTest.java b/src/test/java/fr/univlehavre/entree/PersonneTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..575424627ef01129720a91d505722a03cc70aa2e
--- /dev/null
+++ b/src/test/java/fr/univlehavre/entree/PersonneTest.java
@@ -0,0 +1,22 @@
+package fr.univlehavre.entree;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class PersonneTest {
+
+ @Test
+ void testToString() {
+ Personne p = new Personne("Potter", new String[]{"Prince", "Edouard"}, Genre.HOMME, null, null, "Sorcier");
+ String abregee1 = p.toString(Presentation.ABREGE, Sens.NOM_PRENOMS);
+ String abregee2 = p.toString(Presentation.ABREGE, Sens.PRENOMS_NOM);
+ String simple = p.toString(Presentation.SIMPLE, Sens.NOM_PRENOMS);
+ String complete = p.toString(Presentation.COMPLET, Sens.NOM_PRENOMS);
+
+ assertEquals(abregee1, "Potter P. E. ", "Test abregee 1 NOM_PRENOMS");
+ assertEquals(abregee2, "P. E. Potter", "Test abregee 2 PRENOMS_NOM");
+ assertEquals(simple, "M. Prince E. (Sorcier)", "Test simple NOM_PRENOMS");
+ assertEquals(complete, "M. Prince Edouard Potter", "Test complete NOM_PRENOMS");
+ }
+}