diff --git a/ENSIM/Java/POOtpnote/.idea/workspace.xml b/ENSIM/Java/POOtpnote/.idea/workspace.xml index 4e3f6f3..4f180cf 100644 --- a/ENSIM/Java/POOtpnote/.idea/workspace.xml +++ b/ENSIM/Java/POOtpnote/.idea/workspace.xml @@ -2,7 +2,15 @@ + + + + + + + + @@ -22,24 +30,24 @@ - + - + - + - + @@ -49,8 +57,20 @@ - - + + + + + + + + + + + + + + @@ -61,8 +81,8 @@ - - + + @@ -76,6 +96,20 @@ + + + + + + + + + + + + + + @@ -106,11 +140,11 @@ - + - - + + @@ -119,8 +153,8 @@ - - + + @@ -129,12 +163,14 @@ - - + + + + @@ -184,8 +220,6 @@ @@ -282,7 +319,7 @@ - + @@ -301,7 +338,7 @@ - + + + + @@ -343,15 +390,6 @@ - - - - - - - - - @@ -373,6 +411,15 @@ + + + + + + + + + @@ -392,7 +439,7 @@ - + @@ -400,7 +447,7 @@ - + @@ -433,18 +480,6 @@ - - - - - - - - - - - - @@ -545,18 +580,6 @@ - - - - - - - - - - - - @@ -583,10 +606,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -599,34 +676,16 @@ - + - - + + - - - - - - - - - - - - - - - - - - diff --git a/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java b/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java index 9a82ca5..817c7b9 100644 --- a/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java +++ b/ENSIM/Java/POOtpnote/src/main/java/entity/Administrateur.java @@ -118,11 +118,6 @@ public class Administrateur extends Employe { } } - /*public Agence getAgencePlusMaterielDefectueux() - { - - }*/ - public void achatDeMateriel(Empruntable empruntable) { entreprise.ajouterAuStock(empruntable); diff --git a/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java b/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java index dfc0243..33a2837 100644 --- a/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java +++ b/ENSIM/Java/POOtpnote/src/main/java/entity/Agence.java @@ -3,7 +3,7 @@ package entity; import java.util.ArrayList; import java.util.List; -public class Agence extends Emprunteur { +public class Agence extends Emprunteur implements Comparable { private List employes; private String nom; @@ -31,4 +31,24 @@ public class Agence extends Emprunteur { return stock; } + + public int getNbMaterielDefectueux() + { + int nb = 0; + + for(Empruntable empruntable : listeMateriel()) + { + if(empruntable.isDefectueux()) + { + nb++; + } + } + + return nb; + } + + public int compareTo(Agence o) + { + return (getNbMaterielDefectueux() - o.getNbMaterielDefectueux()); + } } diff --git a/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java b/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java index 966b0cb..d8191bd 100644 --- a/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java +++ b/ENSIM/Java/POOtpnote/src/main/java/entity/Emprunteur.java @@ -3,7 +3,7 @@ package entity; import java.util.ArrayList; import java.util.List; -public class Emprunteur { +public class Emprunteur{ private List stock; diff --git a/ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java b/ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java new file mode 100644 index 0000000..88e92d5 --- /dev/null +++ b/ENSIM/Java/POOtpnote/src/test/java/AgenceTest.java @@ -0,0 +1,37 @@ +import entity.Agence; +import entity.Empruntable; +import entity.Emprunteur; +import material.CasqueAvecMicro; +import material.TELPortable; +import material.UC; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class AgenceTest { + + Agence a1; + Agence a2; + + @Before + public void setUp() { + a1 = new Agence("Le Mans"); + a2 = new Agence("Paris"); + } + + @Test + public void compareAgence() { + Empruntable e1 = new UC(); + Empruntable e2 = new CasqueAvecMicro(); + Empruntable e3 = new TELPortable(); + + e1.declarerDefectueux(); + + a1.ajouterAuStock(e1); + a2.ajouterAuStock(e2); + a2.ajouterAuStock(e3); + + //Test si a1 a plus d'object défectueux que a2 + Assert.assertEquals("compareTo: fail", a1.compareTo(a2) == 1, true); + } +} diff --git a/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java b/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java index 5bbd730..85c226b 100644 --- a/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java +++ b/ENSIM/Java/POOtpnote/src/test/java/EmprunteurTest.java @@ -4,8 +4,8 @@ import entity.Empruntable; import entity.Emprunteur; import material.UC; import org.junit.Assert; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; +import org.junit.Before; +import org.junit.Test; import java.util.ArrayList; @@ -14,9 +14,8 @@ import java.util.ArrayList; public class EmprunteurTest { static Emprunteur e1; - //TODO Passage de @Before à @BeforeAll + passage de la méthode en static - @BeforeAll - public static void setUp() { + @Before + public void setUp() { e1 = new Emprunteur(); } diff --git a/ENSIM/Java/POOtpnote/target/classes/entity/Administrateur.class b/ENSIM/Java/POOtpnote/target/classes/entity/Administrateur.class index 8ef6e1a..ce18383 100644 Binary files a/ENSIM/Java/POOtpnote/target/classes/entity/Administrateur.class and b/ENSIM/Java/POOtpnote/target/classes/entity/Administrateur.class differ diff --git a/ENSIM/Java/POOtpnote/target/classes/entity/Agence.class b/ENSIM/Java/POOtpnote/target/classes/entity/Agence.class index 9790296..2bf7536 100644 Binary files a/ENSIM/Java/POOtpnote/target/classes/entity/Agence.class and b/ENSIM/Java/POOtpnote/target/classes/entity/Agence.class differ diff --git a/ENSIM/Java/POOtpnote/target/test-classes/AgenceTest.class b/ENSIM/Java/POOtpnote/target/test-classes/AgenceTest.class new file mode 100644 index 0000000..e47e6c0 Binary files /dev/null and b/ENSIM/Java/POOtpnote/target/test-classes/AgenceTest.class differ diff --git a/ENSIM/Java/POOtpnote/target/test-classes/EmprunteurTest.class b/ENSIM/Java/POOtpnote/target/test-classes/EmprunteurTest.class index 890fcd8..b5c00dd 100644 Binary files a/ENSIM/Java/POOtpnote/target/test-classes/EmprunteurTest.class and b/ENSIM/Java/POOtpnote/target/test-classes/EmprunteurTest.class differ