diff --git a/.classpath b/.classpath
new file mode 100755
index 0000000..60b915a
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100755
index 0000000..3387902
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ Forum_TD1&2
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 0000000..08c4bff
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=11
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
diff --git a/bin/forum/Administrateur.class b/bin/forum/Administrateur.class
new file mode 100755
index 0000000..04a3d81
Binary files /dev/null and b/bin/forum/Administrateur.class differ
diff --git a/bin/forum/Canal.class b/bin/forum/Canal.class
new file mode 100755
index 0000000..c225a75
Binary files /dev/null and b/bin/forum/Canal.class differ
diff --git a/bin/forum/CanalDeBreve.class b/bin/forum/CanalDeBreve.class
new file mode 100755
index 0000000..de00946
Binary files /dev/null and b/bin/forum/CanalDeBreve.class differ
diff --git a/bin/forum/CanalParDefaut.class b/bin/forum/CanalParDefaut.class
new file mode 100755
index 0000000..701abee
Binary files /dev/null and b/bin/forum/CanalParDefaut.class differ
diff --git a/bin/forum/Controleur.class b/bin/forum/Controleur.class
new file mode 100755
index 0000000..81eb317
Binary files /dev/null and b/bin/forum/Controleur.class differ
diff --git a/bin/forum/Forum.class b/bin/forum/Forum.class
new file mode 100755
index 0000000..1fed953
Binary files /dev/null and b/bin/forum/Forum.class differ
diff --git a/bin/forum/GestionnaireCanal.class b/bin/forum/GestionnaireCanal.class
new file mode 100755
index 0000000..d93b1d6
Binary files /dev/null and b/bin/forum/GestionnaireCanal.class differ
diff --git a/bin/forum/GestionnaireForum.class b/bin/forum/GestionnaireForum.class
new file mode 100755
index 0000000..b5de301
Binary files /dev/null and b/bin/forum/GestionnaireForum.class differ
diff --git a/bin/forum/Memoire.class b/bin/forum/Memoire.class
new file mode 100755
index 0000000..7c3e718
Binary files /dev/null and b/bin/forum/Memoire.class differ
diff --git a/bin/forum/Message.class b/bin/forum/Message.class
new file mode 100755
index 0000000..4a4a717
Binary files /dev/null and b/bin/forum/Message.class differ
diff --git a/bin/forum/Producteur.class b/bin/forum/Producteur.class
new file mode 100755
index 0000000..7602ebf
Binary files /dev/null and b/bin/forum/Producteur.class differ
diff --git a/bin/forum/UserConsole.class b/bin/forum/UserConsole.class
new file mode 100755
index 0000000..c414845
Binary files /dev/null and b/bin/forum/UserConsole.class differ
diff --git a/bin/openClosedPrinciples/core/AlreadyBooked.class b/bin/openClosedPrinciples/core/AlreadyBooked.class
new file mode 100644
index 0000000..4160e36
Binary files /dev/null and b/bin/openClosedPrinciples/core/AlreadyBooked.class differ
diff --git a/bin/openClosedPrinciples/core/AucunItemCorrespondant.class b/bin/openClosedPrinciples/core/AucunItemCorrespondant.class
new file mode 100644
index 0000000..9bf3c8a
Binary files /dev/null and b/bin/openClosedPrinciples/core/AucunItemCorrespondant.class differ
diff --git a/bin/openClosedPrinciples/core/Car.class b/bin/openClosedPrinciples/core/Car.class
new file mode 100644
index 0000000..1ea8282
Binary files /dev/null and b/bin/openClosedPrinciples/core/Car.class differ
diff --git a/bin/openClosedPrinciples/core/CarRental.class b/bin/openClosedPrinciples/core/CarRental.class
new file mode 100644
index 0000000..8d5442f
Binary files /dev/null and b/bin/openClosedPrinciples/core/CarRental.class differ
diff --git a/bin/openClosedPrinciples/core/CarRentalService.class b/bin/openClosedPrinciples/core/CarRentalService.class
new file mode 100644
index 0000000..f331bef
Binary files /dev/null and b/bin/openClosedPrinciples/core/CarRentalService.class differ
diff --git a/bin/openClosedPrinciples/core/CarRentalServiceTest.class b/bin/openClosedPrinciples/core/CarRentalServiceTest.class
new file mode 100644
index 0000000..0681fae
Binary files /dev/null and b/bin/openClosedPrinciples/core/CarRentalServiceTest.class differ
diff --git a/bin/openClosedPrinciples/core/CarRentalTest.class b/bin/openClosedPrinciples/core/CarRentalTest.class
new file mode 100644
index 0000000..f03eb5e
Binary files /dev/null and b/bin/openClosedPrinciples/core/CarRentalTest.class differ
diff --git a/bin/openClosedPrinciples/core/DateTools.class b/bin/openClosedPrinciples/core/DateTools.class
new file mode 100644
index 0000000..c8bad04
Binary files /dev/null and b/bin/openClosedPrinciples/core/DateTools.class differ
diff --git a/bin/openClosedPrinciples/core/Description.class b/bin/openClosedPrinciples/core/Description.class
new file mode 100644
index 0000000..9f2078d
Binary files /dev/null and b/bin/openClosedPrinciples/core/Description.class differ
diff --git a/bin/openClosedPrinciples/core/Flight.class b/bin/openClosedPrinciples/core/Flight.class
new file mode 100644
index 0000000..fbb02f7
Binary files /dev/null and b/bin/openClosedPrinciples/core/Flight.class differ
diff --git a/bin/openClosedPrinciples/core/FlightService.class b/bin/openClosedPrinciples/core/FlightService.class
new file mode 100644
index 0000000..352526e
Binary files /dev/null and b/bin/openClosedPrinciples/core/FlightService.class differ
diff --git a/bin/openClosedPrinciples/core/FlightServiceTest.class b/bin/openClosedPrinciples/core/FlightServiceTest.class
new file mode 100644
index 0000000..8e8fc34
Binary files /dev/null and b/bin/openClosedPrinciples/core/FlightServiceTest.class differ
diff --git a/bin/openClosedPrinciples/core/FlightTest.class b/bin/openClosedPrinciples/core/FlightTest.class
new file mode 100644
index 0000000..768b341
Binary files /dev/null and b/bin/openClosedPrinciples/core/FlightTest.class differ
diff --git a/bin/openClosedPrinciples/core/GestionnaireVoyages.class b/bin/openClosedPrinciples/core/GestionnaireVoyages.class
new file mode 100644
index 0000000..f038aff
Binary files /dev/null and b/bin/openClosedPrinciples/core/GestionnaireVoyages.class differ
diff --git a/bin/openClosedPrinciples/core/NotPossibleCarRentalException.class b/bin/openClosedPrinciples/core/NotPossibleCarRentalException.class
new file mode 100644
index 0000000..acfad9e
Binary files /dev/null and b/bin/openClosedPrinciples/core/NotPossibleCarRentalException.class differ
diff --git a/bin/openClosedPrinciples/core/PayingItem.class b/bin/openClosedPrinciples/core/PayingItem.class
new file mode 100644
index 0000000..d899994
Binary files /dev/null and b/bin/openClosedPrinciples/core/PayingItem.class differ
diff --git a/bin/openClosedPrinciples/core/Service.class b/bin/openClosedPrinciples/core/Service.class
new file mode 100644
index 0000000..0e03490
Binary files /dev/null and b/bin/openClosedPrinciples/core/Service.class differ
diff --git a/bin/openClosedPrinciples/core/TravelOrganizer.class b/bin/openClosedPrinciples/core/TravelOrganizer.class
new file mode 100644
index 0000000..2c33083
Binary files /dev/null and b/bin/openClosedPrinciples/core/TravelOrganizer.class differ
diff --git a/bin/openClosedPrinciples/core/Trip.class b/bin/openClosedPrinciples/core/Trip.class
new file mode 100644
index 0000000..e251365
Binary files /dev/null and b/bin/openClosedPrinciples/core/Trip.class differ
diff --git a/bin/td5/p1/Launch.class b/bin/td5/p1/Launch.class
new file mode 100644
index 0000000..1fde4c3
Binary files /dev/null and b/bin/td5/p1/Launch.class differ
diff --git a/bin/td5/p1/ModernWeaponFactory.class b/bin/td5/p1/ModernWeaponFactory.class
new file mode 100644
index 0000000..7237a49
Binary files /dev/null and b/bin/td5/p1/ModernWeaponFactory.class differ
diff --git a/bin/td5/p1/WeaponFactory.class b/bin/td5/p1/WeaponFactory.class
new file mode 100644
index 0000000..d25744c
Binary files /dev/null and b/bin/td5/p1/WeaponFactory.class differ
diff --git a/bin/td5/p1/arme/Arme.class b/bin/td5/p1/arme/Arme.class
new file mode 100644
index 0000000..38b457e
Binary files /dev/null and b/bin/td5/p1/arme/Arme.class differ
diff --git a/bin/td5/p1/arme/Bouclier.class b/bin/td5/p1/arme/Bouclier.class
new file mode 100644
index 0000000..c0fabd7
Binary files /dev/null and b/bin/td5/p1/arme/Bouclier.class differ
diff --git a/bin/td5/p1/arme/Dague.class b/bin/td5/p1/arme/Dague.class
new file mode 100644
index 0000000..db3b43c
Binary files /dev/null and b/bin/td5/p1/arme/Dague.class differ
diff --git a/bin/td5/p1/arme/Epée.class b/bin/td5/p1/arme/Epée.class
new file mode 100644
index 0000000..a7d8b34
Binary files /dev/null and b/bin/td5/p1/arme/Epée.class differ
diff --git a/bin/td5/p1/arme/Fusil.class b/bin/td5/p1/arme/Fusil.class
new file mode 100644
index 0000000..b0a55e5
Binary files /dev/null and b/bin/td5/p1/arme/Fusil.class differ
diff --git a/bin/td5/p1/etat/Faible.class b/bin/td5/p1/etat/Faible.class
new file mode 100644
index 0000000..d27777d
Binary files /dev/null and b/bin/td5/p1/etat/Faible.class differ
diff --git a/bin/td5/p1/etat/Mort.class b/bin/td5/p1/etat/Mort.class
new file mode 100644
index 0000000..401ee99
Binary files /dev/null and b/bin/td5/p1/etat/Mort.class differ
diff --git a/bin/td5/p1/etat/PlayerState.class b/bin/td5/p1/etat/PlayerState.class
new file mode 100644
index 0000000..8f68878
Binary files /dev/null and b/bin/td5/p1/etat/PlayerState.class differ
diff --git a/bin/td5/p1/etat/Vivant.class b/bin/td5/p1/etat/Vivant.class
new file mode 100644
index 0000000..16b0a6e
Binary files /dev/null and b/bin/td5/p1/etat/Vivant.class differ
diff --git a/bin/td5/p1/personnage/Humain.class b/bin/td5/p1/personnage/Humain.class
new file mode 100644
index 0000000..3ca4023
Binary files /dev/null and b/bin/td5/p1/personnage/Humain.class differ
diff --git a/bin/td5/p1/personnage/Orc.class b/bin/td5/p1/personnage/Orc.class
new file mode 100644
index 0000000..0a536ee
Binary files /dev/null and b/bin/td5/p1/personnage/Orc.class differ
diff --git a/bin/td5/p1/personnage/Personnage.class b/bin/td5/p1/personnage/Personnage.class
new file mode 100644
index 0000000..bd0e9dd
Binary files /dev/null and b/bin/td5/p1/personnage/Personnage.class differ
diff --git a/bin/td5/p1/personnage/Tauren.class b/bin/td5/p1/personnage/Tauren.class
new file mode 100644
index 0000000..a84f184
Binary files /dev/null and b/bin/td5/p1/personnage/Tauren.class differ
diff --git a/bin/td5/p1/personnage/Troll.class b/bin/td5/p1/personnage/Troll.class
new file mode 100644
index 0000000..164fec8
Binary files /dev/null and b/bin/td5/p1/personnage/Troll.class differ
diff --git a/bin/td5/p1/td5p1.png b/bin/td5/p1/td5p1.png
new file mode 100644
index 0000000..b863fc4
Binary files /dev/null and b/bin/td5/p1/td5p1.png differ
diff --git a/bin/td5/p1/testArmes.class b/bin/td5/p1/testArmes.class
new file mode 100644
index 0000000..f628596
Binary files /dev/null and b/bin/td5/p1/testArmes.class differ
diff --git a/src/Diagramme_de_classe_forum.ucls b/src/Diagramme_de_classe_forum.ucls
new file mode 100755
index 0000000..395f71b
--- /dev/null
+++ b/src/Diagramme_de_classe_forum.ucls
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/designPattern/facebookGhost/Event.java b/src/designPattern/facebookGhost/Event.java
new file mode 100644
index 0000000..9d8e17d
--- /dev/null
+++ b/src/designPattern/facebookGhost/Event.java
@@ -0,0 +1,5 @@
+package designPattern.facebookGhost;
+
+public interface Event {
+
+}
diff --git a/src/designPattern/facebookGhost/FacebookGhostNetwork.java b/src/designPattern/facebookGhost/FacebookGhostNetwork.java
new file mode 100644
index 0000000..eea1e33
--- /dev/null
+++ b/src/designPattern/facebookGhost/FacebookGhostNetwork.java
@@ -0,0 +1,125 @@
+package designPattern.facebookGhost;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Observable;
+
+
+/**
+ *
+ * Inspired by
+ * //https://github.com/roundrop/facebook4j/blob/master/facebook4j-core/src/main/java/facebook4j/api/FriendMethods.java
+ * pour imaginer une esquisse de rseau tr�s tr�s simplifi�
+ * @author blay
+ *
+ */
+@SuppressWarnings("deprecation")
+public class FacebookGhostNetwork extends Observable {
+
+ public static final String DEFAULT_LOCATION = "unspecified";
+ HashMap users = new HashMap<> ();
+
+ public FacebookGhostNetwork() {
+ }
+
+
+ public User addUser(String nom, String profile){
+ return addUser(nom, profile,DEFAULT_LOCATION);
+ }
+
+ public User addUser(String nom, String profile, String location){
+ User user = new UserImpl(nom, profile,location);
+ users.put(nom, user);
+ Event e = new UserEvent(user);
+ setChanged();
+ notifyObservers(e);
+ return user;
+ }
+
+ /**
+ * Returns a user's friends.
+ * @param userId the ID of a user
+ * @return users
+ * @see User#friends - Facebook Developers
+ */
+ ArrayList getFriends(String userId){
+ return getUser(userId).getFriends();
+ }
+
+
+ /**
+ * Returns a user's family members.
+ * @param userId the ID of a user
+ * @return users
+ * @see User#friends - Facebook Developers
+ */
+ ArrayList getFamily(String userId){
+ return getUser(userId).getFamily();
+ }
+
+
+
+ /**
+ * Returns a given user, specified by ID.
+ * @param userId the ID of the user
+ * @return user
+ * remove but not the use of dedicated exception !! @throws FacebookException when Facebook service or network is unavailable
+ * @see User - Facebook Developers
+ */
+ public User getUser(String userId) {
+ return users.get(userId);
+ }
+
+
+ /**
+ * Create a relation between 2 given members of a same family
+ * @param id1 the ID of the user
+ * @param id2 the ID of the user
+ */
+ public void addFamilyRelation(String id1, String id2) {
+ User u1 = users.get(id1);
+ User u2 = users.get(id2);
+ addFamilyRelation(u1, u2);
+
+ }
+
+
+ public void addFamilyRelation(User u1, User u2) {
+ u1.addFamily(u2);
+ u2.addFamily(u1);
+ Event e = new RelationEvent("family",u1,u2);
+ setChanged();
+ notifyObservers(e);
+
+ }
+
+
+
+ /**
+ * Create a relation between 2 given friends
+ * @param id1 the ID of the user
+ * @param id2 the ID of the user
+ */
+ public void addFriendRelation(String id1, String id2) {
+ User u1 = users.get(id1);
+ User u2 = users.get(id2);
+ addFriendRelation(u1, u2);
+ }
+
+ public void addFriendRelation(User u1, User u2) {
+ u1.addFriend(u2);
+ u2.addFriend(u1);
+ Event e = new RelationEvent("Friend",u1,u2);
+ setChanged();
+ notifyObservers(e);
+
+ }
+ @Override
+ public String toString() {
+ return "FacebookGhostNetwork [ " + users + "]";
+ }
+
+
+
+
+}
diff --git a/src/designPattern/facebookGhost/IdNameEntity.java b/src/designPattern/facebookGhost/IdNameEntity.java
new file mode 100644
index 0000000..71b77e0
--- /dev/null
+++ b/src/designPattern/facebookGhost/IdNameEntity.java
@@ -0,0 +1,6 @@
+package designPattern.facebookGhost;
+
+public interface IdNameEntity {
+ String getId();
+ String getName();
+}
diff --git a/src/designPattern/facebookGhost/IdNameEntityImpl.java b/src/designPattern/facebookGhost/IdNameEntityImpl.java
new file mode 100644
index 0000000..62eaab6
--- /dev/null
+++ b/src/designPattern/facebookGhost/IdNameEntityImpl.java
@@ -0,0 +1,25 @@
+package designPattern.facebookGhost;
+
+public class IdNameEntityImpl implements IdNameEntity {
+
+ private String id;
+ private String name;
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public IdNameEntityImpl(String id, String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+
+}
diff --git a/src/designPattern/facebookGhost/RelationEvent.java b/src/designPattern/facebookGhost/RelationEvent.java
new file mode 100644
index 0000000..27307f2
--- /dev/null
+++ b/src/designPattern/facebookGhost/RelationEvent.java
@@ -0,0 +1,32 @@
+package designPattern.facebookGhost;
+
+public class RelationEvent implements Event {
+ public String getNature() {
+ return nature;
+ }
+
+ public User getU1() {
+ return u1;
+ }
+
+ public User getU2() {
+ return u2;
+ }
+
+ String nature;
+ User u1;
+ User u2;
+
+ public RelationEvent(String nature, User u1, User u2) {
+ this.nature = nature;
+ this.u1 = u1;
+ this.u2=u2;
+ }
+
+ @Override
+ public String toString() {
+ return "RelationEvent [nature=" + nature + ", u1=" + u1 + ", u2=" + u2
+ + "]";
+ }
+
+}
diff --git a/src/designPattern/facebookGhost/User.java b/src/designPattern/facebookGhost/User.java
new file mode 100644
index 0000000..39b97c6
--- /dev/null
+++ b/src/designPattern/facebookGhost/User.java
@@ -0,0 +1,104 @@
+package designPattern.facebookGhost;
+
+/*import java.net.URL;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;*/
+
+import java.util.ArrayList;
+
+/**
+ * Emprunt� � https://github.com/roundrop/facebook4j
+ * @author Ryuji Yamashita - roundrop at gmail.com
+ */
+public interface User {
+
+ String myProfil();
+ String getId();
+ String getName();
+ /* String getFirstName();
+ String getMiddleName();
+ String getLastName();
+ String getGender();
+ Locale getLocale();
+ List getLanguages();
+ URL getLink();
+ String getUsername();
+ String getThirdPartyId();
+ Boolean isInstalled();
+ Double getTimezone();
+ Date getUpdatedTime();
+ Boolean isVerified();
+ String getBio();
+ String getBirthday();
+// Cover getCover();
+ List getEducation();
+ String getEmail();
+ */
+ IdNameEntity getHometown();
+ /*
+ List getInterestedIn();
+ IdNameEntity getLocation();
+ String getPolitical();
+ List getFavoriteAthletes();
+ List getFavoriteTeams();
+// Picture getPicture();
+ String getQuotes();
+ String getRelationshipStatus();
+ String getReligion();
+ IdNameEntity getSignificantOther();
+ User.VideoUploadLimits getVideoUploadLimits();
+ URL getWebsite();
+ List getWork();
+;
+
+ interface Education {
+ IdNameEntity getYear();
+ String getType();
+ IdNameEntity getSchool();
+ IdNameEntity getDegree();
+ List getConcentration();
+ List getClasses();
+ List getWith();
+ }
+
+ interface EducationClass {
+ List getWith();
+ String getDescription();
+ }
+
+ interface VideoUploadLimits {
+ long getLength();
+ long getSize();
+ }
+
+ interface Work {
+ IdNameEntity getEmployer();
+ IdNameEntity getLocation();
+ IdNameEntity getPosition();
+ String getStartDate();
+ String getEndDate();
+
+ }*/
+
+ User.AgeRange getAgeRange();
+ interface AgeRange {
+ // one value could be null (13-17 / 18-20 / 21 - null)
+ Integer getMin();
+ Integer getMax();
+ int getAge();
+ }
+ ArrayList getFriends();
+ void addFriend(User friend);
+ void addFamily(User familyMember);
+ ArrayList getFamily();
+
+ void setLocation(String name);
+ //String BIRTHDAY_DATE_FORMAT = "MM/dd/yyyy";
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/designPattern/facebookGhost/UserEvent.java b/src/designPattern/facebookGhost/UserEvent.java
new file mode 100644
index 0000000..424f8ff
--- /dev/null
+++ b/src/designPattern/facebookGhost/UserEvent.java
@@ -0,0 +1,11 @@
+package designPattern.facebookGhost;
+
+public class UserEvent implements Event {
+
+ User user;
+
+ public UserEvent(User user) {
+ this.user = user;
+ }
+
+}
diff --git a/src/designPattern/facebookGhost/UserImpl.java b/src/designPattern/facebookGhost/UserImpl.java
new file mode 100644
index 0000000..db222c6
--- /dev/null
+++ b/src/designPattern/facebookGhost/UserImpl.java
@@ -0,0 +1,105 @@
+package designPattern.facebookGhost;
+
+import java.util.ArrayList;
+
+
+public class UserImpl implements User {
+
+
+ private String id;
+ private String myProfile;
+ private User.AgeRange range;
+ private IdNameEntity homeTown;
+
+
+ class AgeRangeImpl implements User.AgeRange{
+
+ int age = 20;
+ public Integer getMin() {
+ return 0;
+ }
+
+ public Integer getMax() {
+ return 120;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ }
+
+
+ public UserImpl(String id, String profile, String phomeTown) {
+ this.id = id;
+ myProfile = profile;
+ range = new AgeRangeImpl();
+ homeTown = new IdNameEntityImpl(phomeTown,phomeTown);
+ }
+
+
+ public UserImpl(String id, String profile) {
+ this.id = id;
+ myProfile = profile;
+ range = new AgeRangeImpl();
+ }
+
+ public String myProfil() {
+ return myProfile;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return id;
+ }
+
+ public AgeRange getAgeRange() {
+ return range;
+ }
+
+
+
+ private ArrayList friends = new ArrayList ();
+
+ public void addFriend(User friend) {
+ friends.add(friend);
+ }
+
+ public ArrayList getFriends() {
+ return friends;
+ }
+
+ private ArrayList family = new ArrayList ();
+
+ public void addFamily(User familyMember) {
+ family.add(familyMember);
+ }
+
+ public ArrayList getFamily(){
+ return family;
+ }
+
+ @Override
+ public String toString() {
+ return "UserImpl [id=" + id + ", myProfile=" + myProfile + ", range="
+ + range +
+ //",friends=" + friends + ", family=" + family +
+ "]";
+ }
+
+ @Override
+ public IdNameEntity getHometown() {
+ return homeTown;
+ }
+
+
+ @Override
+ public void setLocation(String name) {
+ homeTown = new IdNameEntityImpl(name,name) ;
+ }
+
+
+}
diff --git a/src/designPattern/grapheSimple/Chemin.java b/src/designPattern/grapheSimple/Chemin.java
new file mode 100644
index 0000000..527f79a
--- /dev/null
+++ b/src/designPattern/grapheSimple/Chemin.java
@@ -0,0 +1,192 @@
+package designPattern.grapheSimple;
+
+import designPattern.grapheX.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * La classe Chemin définit un chemin comme un ensemble d'arcs et maintient pour
+ * chaque chemin la somme des valeurs des arcs
+ *
+ * @author blay
+ * @param
+ *
+ */
+public class Chemin implements Comparable> {
+
+ // On pourrait éviter cet attribut en calculant la distance à la demande.
+ int distance = 0;
+
+ List> paths = new ArrayList<>();
+
+ public Chemin() {
+ paths = new ArrayList<>();
+ }
+
+ public Chemin(List> arcs) {
+ paths = arcs;
+ }
+
+ /**
+ * @return le Sommet terminant le chemin si le chemin est vide il vaut null
+ */
+ public S arrivee() {
+ if (paths.isEmpty())
+ return null;
+ Arc arc = paths.get(paths.size() - 1);
+ return arc.destination();
+ }
+
+ /**
+ * @return la somme des valeurs des arcs
+ */
+ public int distance() {
+ return distance;
+ }
+
+ /**
+ * @return la liste des arcs qui composent le chemin Attention dangereux une
+ * copie serait préférable
+ */
+ public List> getArcs() {
+ return paths;
+ }
+
+ /**
+ * Ajoute un arc � la fin du chemin
+ *
+ * @TODO : verifier que le dernier noeud est bien le premier noeud de l'arc
+ * ajoute
+ */
+ public boolean add(Arc e) {
+ distance += e.valeur();
+ return paths.add(e);
+ }
+
+ public void add(int x, Arc e) {
+ distance += e.valeur();
+ paths.add(x, e);
+ }
+
+ public boolean addAll(Collection> c) {
+ for (Arc a : c)
+ distance += a.valeur();
+ return paths.addAll(c);
+ }
+
+ public void clear() {
+ distance = 0;
+ paths.clear();
+
+ }
+
+ /**
+ * verifie l'appartenance d'un arc au chemin
+ *
+ * @param arc
+ * @return vrai si l'arc appartient au chemin
+ */
+ public boolean contains(Arc arc) {
+ return paths.contains(arc);
+ }
+
+ public boolean isEmpty() {
+ return paths.isEmpty();
+ }
+
+ public boolean remove(Arc o) {
+ return paths.remove(o);
+ }
+
+ public boolean removeAll(Collection> c) {
+ return paths.removeAll(c);
+ }
+
+ public int size() {
+ return paths.size();
+ }
+
+ @Override
+ public String toString() {
+ return "Chemin [dist.=" + distance + ", paths=" + paths + "]";
+ }
+
+ /**
+ * d�termine si le sommet appartient au chemin
+ *
+ * @param sommet
+ * @return vrai si le sommet appartient au chemin
+ */
+ public boolean atteint(S sommet) {
+ for (Arc a : paths)
+ if (a.destination().equals(sommet))
+ return true;
+ return false;
+ }
+
+ /**
+ * @param depart
+ * @param arrivee
+ * @return le sous-chemin reliant depart et arrivee si les deux noeuds
+ * appartiennent au chemin.
+ *
+ */
+ public Chemin extraireChemin(S depart, S arrivee) {
+ boolean debutee = false;
+ Chemin c = new Chemin<>();
+ for (Arc a : paths) {
+ if (debutee) {
+ c.add(a);
+ }
+ if (a.origine().equals(depart)) {
+ c.add(a);
+ debutee = true;
+ }
+ if (debutee && a.destination().equals(arrivee))
+ return c;
+ }
+ return c;
+
+ }
+
+ public int compareTo(Chemin c) {
+ if (this.distance() < c.distance())
+ return -1;
+ else if (this.distance() == c.distance())
+ return 0;
+ else
+ return 1;
+
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof Chemin))
+ return false;
+
+ Chemin o2 = (Chemin) o;
+ Chemin c = o2;
+ if ((distance == c.distance) && (c.paths.size() == this.paths.size())) {
+ for (Arc a : c.paths) {
+ if (!paths.contains(a)) {
+ return false;
+ }
+ }
+ return true;
+ } else
+ return false;
+
+ }
+
+ public List sommets() {
+ List sommets = new ArrayList<>();
+ if (! paths.isEmpty()) {
+ for (Arc arc : paths)
+ sommets.add(arc.origine());
+ sommets.add(paths.get(paths.size() - 1).destination());
+ }
+ return sommets;
+ }
+
+}
diff --git a/src/designPattern/grapheSimple/GrapheSimple.java b/src/designPattern/grapheSimple/GrapheSimple.java
new file mode 100644
index 0000000..c86d0cd
--- /dev/null
+++ b/src/designPattern/grapheSimple/GrapheSimple.java
@@ -0,0 +1,260 @@
+package designPattern.grapheSimple;
+
+import designPattern.grapheX.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Cette classe a ete necessaire pour gérer les graphes ayant plusieurs arétes entre deux sommets données
+ * et ayant des arcs dans les deux sens entre deux sommets.
+ * Ces fonctionnalités n'étaient pas prises en charge par les classes initiales.
+ * Elle permet egalement de simplifier la comprehension des codes données.
+ * @author blay
+ *
+ */
+public class GrapheSimple extends Graphe {
+ HashMap mesSommets = new HashMap<>();
+
+ HashMap>>> aretes;
+
+
+ public GrapheSimple() {
+ aretes = new HashMap<>();
+ }
+
+
+ public T getSommet(String ident){
+ return mesSommets.get(ident);
+ }
+
+ @Override
+ public int taille() {
+ return mesSommets.size();
+ }
+
+
+ @Override
+
+ public Graphe copie() {
+ //@TODO
+ return null;
+ }
+
+ //n'ajoute le sommet que s'il n'est pas deja dans le graphe.
+ @Override
+ public void ajouterSommet(T s) {
+ if (existeSommet(s))
+ return;
+ mesSommets.put(s.identifiant(), s);
+ aretes.put(s,new HashMap>>());
+ }
+
+ @Override
+ public boolean existeArc(Sommet s, Sommet t) {
+ return aretes.get(s).containsKey(t);
+ }
+
+
+ //A revoir avec la nouvelle version
+ //@todo
+ private boolean existeSommet(T s) {
+ return aretes.containsKey(s);
+ }
+
+
+ public List> arcs(T s, T t) {
+ return aretes.get(s).get(t);
+ }
+
+ @Override
+ public void ajouterArc(T s, T t) {
+ this.ajouterArc(s,t,0);
+ }
+
+
+ @Override
+ public void ajouterArc(Arc arc) {
+ HashMap>> s = aretes.get(arc.origine());
+ if (s == null){
+ ajouterSommet(arc.origine());
+ s=aretes.get(arc.origine());
+ }
+ if (aretes.get(arc.destination()) == null)
+ ajouterSommet(arc.destination());
+ if (s.get(arc.destination()) == null)
+ s.put(arc.destination(), new ArrayList<>());
+ s.get(arc.destination()).add(arc);
+
+ }
+ @Override
+ public void ajouterArc(T s, T t, int val) {
+ Arc a = new Arc<>(s,t,val);
+ this.ajouterArc(a);
+ }
+
+ //Remarque : gestion horrible des exceptions mais on s'adapte à cause de l'héritage qui nous interdit de lever une exception.
+ @Override
+ public int valeurArc(T s, T t) {
+ if (!existeArc(s,t)) throw new Error("Arc inexistant");
+ return aretes.get(s).get(t).get(0).valeur();
+ }
+
+ //RETIRE TOUS LES ARCS VERS T
+ @Override
+ public void enleverArc(Sommet s, Sommet t) {
+ if (!existeArc(s,t)) return ;
+ aretes.get(s).remove(t);
+ }
+
+ @Override
+ public Collection sommets() {
+ return mesSommets.values();
+ }
+
+ @Override
+ public Collection> voisins(Sommet s) {
+ ArrayList> voisins = new ArrayList<>();
+ HashMap>> arcs = aretes.get(s);
+ if ( arcs != null )
+ for (ArrayList> av : arcs.values())
+ voisins.addAll(av);
+ return voisins ;
+ }
+
+ @Override
+ public String toString() {
+ return "Sommets=" + mesSommets + ";\n arcs="
+ + toStringArretes(aretes) + "]";
+ }
+
+ private String toStringArretes(
+ HashMap>>> aretes2) {
+ StringBuilder bld = new StringBuilder();
+ for ( HashMap>> x : aretes2.values()){
+ for ( ArrayList> edges : x.values())
+ for (Arc a : edges)
+ bld.append( "\t").append(a).append("\n" );
+ }
+ return bld.toString();
+ }
+
+
+ /**
+ * @param origine
+ * @return une liste de chemin
+ * Cette m�thode renvoie les chemins les plus longs possibles � partir du point d'orgine
+ */
+ public List> chemins(T origine){
+ HashMap>> dejaVu = new HashMap<>();
+ return chemins(origine,dejaVu);
+ }
+
+ /**
+ * @param origine
+ * @param destination
+ * @return une liste de chemins entre deux Ts
+ * Cette m�thode renvoie tous les chemins entre deux Sommets donnes
+ */
+ //Pbme avec la comparaison des chemins... qui considere comme �gal deux objets diff�rents... cela doit venir de l'h�ritage...
+
+ public List> chemins(T origine, T destination){
+ List> chemins = chemins(origine);
+ List> cheminsEntreDeuxSommets = new ArrayList<> ();
+ for(Chemin c : chemins) {
+ if (c.atteint(destination)){
+ Chemin raccourcis = c.extraireChemin(origine, destination);
+ if (! cheminsEntreDeuxSommets.contains(raccourcis)) {
+ cheminsEntreDeuxSommets.add(raccourcis);
+ }
+ }
+ }
+ return cheminsEntreDeuxSommets;
+ }
+
+
+ private List> chemins(T origine, HashMap>> dejaVu){
+
+ List> chemins = new ArrayList<>();
+
+ if (dejaVu.containsKey(origine)){
+ chemins.add(new Chemin<>(dejaVu.get(origine)));
+ return chemins;
+ }
+
+
+ dejaVu.put(origine, new ArrayList>());
+
+
+ Collection> voisins = voisins(origine);
+ HashMap>> dejavVuLocal ;
+
+ for (Arc a : voisins) {
+ T destination = a.destination();
+ dejavVuLocal= new HashMap<>(dejaVu);
+
+ if (nouvelleDestinationOuNouvelArcSansRetour(origine,dejavVuLocal,destination,a)) {
+ dejavVuLocal.get(origine).add(a);
+ List> cheminsLocaux = chemins(destination,dejavVuLocal);
+ if (cheminsLocaux.isEmpty()) {
+ Chemin chemin = new Chemin<>();
+ chemin.add(a);
+ chemins.add(chemin);
+ }
+ else {
+ for (Chemin c : cheminsLocaux) {
+ c.add(0,a);
+ chemins.add(c);
+ }
+ }
+ }
+ }
+ return chemins;
+ }
+
+ //todo : tenir compte de Origine
+ private boolean nouvelleDestinationOuNouvelArcSansRetour(
+ T origine, HashMap>> dejaVu, T destination,
+ Arc a) {
+
+ if (! dejaVu.containsKey(destination) )
+ return true;
+
+ return ( (! dejaVu.get(destination).contains(a)) && (! dejaVu.containsKey(a.destination()) ) );
+ }
+
+
+ public Chemin cheminLePlusCourt(T origine, T destination){
+ List> chemins = this.chemins(origine, destination);
+ Chemin cheminLePlusCourt = null;
+ int distanceLaPlusCourte = Integer.MAX_VALUE;
+ for(Chemin c : chemins) {
+ if (distanceLaPlusCourte > c.distance()) {
+ distanceLaPlusCourte = c.distance();
+ cheminLePlusCourt = c;
+ }
+ }
+ return cheminLePlusCourt;
+ }
+
+ public Set voisinsAuRang(T origine, int rang){
+ List> chemins = chemins(origine);
+ Set TsVoisinsDejaVu = new TreeSet<>();
+ Set TsDeBonRang = new TreeSet<>();
+ for (Chemin c : chemins) {
+ List sommets = c.sommets();
+ int i = 0;
+ for (i = 0; (i d avec valeur val
+public class Arc implements Comparable> {
+ private S o, d;
+
+ private int val;
+
+ public Arc(S o0, S d0, int val0) {
+ this.o = o0;
+ this.d = d0;
+ this.val = val0;
+ }
+
+ public Arc(S o0, S d0) {
+ this.o = o0;
+ this.d = d0;
+ this.val = 0;
+ }
+
+ public Arc(Arc a) {
+ this.o = a.o;
+ this.d = a.d;
+ this.val = a.val;
+ }
+
+ public S destination() {
+ return d;
+ }
+
+ public S origine() {
+ return o;
+ }
+
+ public int valeur() {
+ return val;
+ }
+
+ public void modifierValeur(int vv) {
+ this.val = vv;
+ }
+
+ @Override
+public String toString() {
+ return "(" + val + ":" + this.o + ", " + this.d + ")";
+ }
+
+ @Override
+public int hashCode() {
+ int codeOri = (o == null ? 0 : o.hashCode());
+ int codeDst = (d == null ? 0 : d.hashCode());
+ return codeDst ^ (codeOri * 31);
+ }
+
+ @Override
+public boolean equals(Object aa) {
+ if (!(aa instanceof Arc))
+ return false;
+ Arc> arc = (Arc>) aa;
+ boolean equalsO = o == null && arc.o == null || o != null
+ && o.equals(arc.o);
+ boolean equalsD = d == null && arc.d == null || d != null
+ && d.equals(arc.d);
+ return equalsO && equalsD && (val == arc.val);
+ }
+
+public int compareTo(Arc a) {
+ int comp = Identifiable.compare(this.o, a.o);
+ if (comp == 0)
+ comp = Identifiable.compare(d, a.d);
+ return comp;
+ }
+
+}
diff --git a/src/designPattern/grapheX/Graphe.java b/src/designPattern/grapheX/Graphe.java
new file mode 100644
index 0000000..9481ecc
--- /dev/null
+++ b/src/designPattern/grapheX/Graphe.java
@@ -0,0 +1,871 @@
+package designPattern.grapheX;
+
+import java.util.*;
+
+/**
+ Classe abstraite de graphes
+
+
+ @author FMorain (morain@lix.polytechnique.fr)
+ @version 2008.03.01
+ @author MBF revisée pour la rendre générique
+ */
+
+public abstract class Graphe extends GrapheGenerique{
+
+ @Override
+public abstract int taille();
+ public abstract Graphe copie();
+
+ @Override
+public abstract void ajouterSommet(T s);
+ @Override
+public abstract boolean existeArc(T s, T t);
+ @Override
+public abstract void ajouterArc(T s, T t, int val);
+ public abstract void ajouterArc(Arc arc);
+ @Override
+public abstract int valeurArc(T s, T t);
+ @Override
+public abstract void enleverArc(T s, T t);
+
+ @Override
+public abstract Collection sommets();
+ @Override
+public abstract Collection> voisins(T s);
+
+ public boolean oriente;
+
+ public static String version(){
+ return "grapheX -- version 1.3d, 2008/02/27";
+ }
+
+ public void ajouterArc(T s, T t){
+ ajouterArc(s, t, 0);
+ }
+
+ public boolean existeArc(Arc alpha){
+ return existeArc(alpha.origine(), alpha.destination());
+ }
+
+
+
+public String toString(){
+ String str = "";
+
+ for(T s : sommets()){
+ str += s + ":";
+ for(T t : sommets()){
+ if(existeArc(s, t))
+ str += " " + valeurArc(s, t);
+ else
+ str += " -";
+ }
+ str += "\n";
+ }
+ return str;
+ }
+
+ /* public void faireComplet(){
+ int n = taille();
+ for(int i = 0; i < n; i++)
+ ajouterSommet(new Sommet(i+""));
+ for(Sommet s : sommets())
+ for(Sommet t : sommets())
+ if(!s.equals(t))
+ ajouterArc(s, t, 1);
+ }
+
+ public static void afficherParcours(HashMap L){
+ System.err.println("PARCOURS");
+ for(Sommet s : L.keySet())
+ System.err.print(" ["+s+", "+L.get(s)+"]");
+ System.err.println();
+ }
+
+ public static Graphe RoyWarshall(Graphe G){
+ Graphe F = G.copie();
+
+ for(Sommet s : G.sommets())
+ F.ajouterArc(s, s, 1);
+ System.err.println("FT_ini = \n"+F);
+ for(Sommet r : G.sommets()){
+ for(Sommet s : G.sommets())
+ for(Sommet t : G.sommets())
+ if(!F.existeArc(s, t)
+ && (F.existeArc(s, r) && F.existeArc(r, t)))
+ F.ajouterArc(s, t, 1);
+ System.err.println("\nA_"+r);
+ System.err.println(F);
+ }
+ return F;
+ }*/
+
+ //////////////////// Dijkstra ////////////////////
+
+ public HashMap Dijkstra(T s){
+ int INFINITY = 1000000;
+ HashMap L = new HashMap();
+
+ // 1. initialisation
+ for(T t : sommets())
+ if(! t.equals(s))
+ if(existeArc(s, t))
+ L.put(t, valeurArc(s, t));
+ else
+ L.put(t, INFINITY);
+ // 2.
+ HashSet U = new HashSet<>(sommets()); // copie
+ L.put(s, 0);
+ U.remove(s);
+ // 3.
+ while(! U.isEmpty()){
+ //afficherParcours(L);
+ // 4.
+ T v = null;
+ int Lv = INFINITY;
+ for(T t : U)
+ if(L.get(t) < Lv){
+ v = t;
+ Lv = L.get(t);
+ }
+ System.err.println("-->v="+v);
+ // 5.
+ U.remove(v);
+ // 6.
+ // for(Sommet t : U)
+ // if(existeArc(v, t)){
+ for(Arc a : voisins(v)){
+ T t = a.destination();
+ int tmp = Lv + a.valeur();
+ if(tmp < L.get(t))
+ L.put(t, tmp);
+ }
+ }
+ return L;
+ }
+/*
+ TreeSet Dijkstra2Init(HashMap L, T s){
+ int INFINITY = 1000000;
+ TreeSet fp =
+ new TreeSet(
+ new Comparator() {
+ public int compare(SommetValue s1, SommetValue s2) {
+ if(s1.valeur < s2.valeur)
+ return -1;
+ else if(s1.valeur > s2.valeur)
+ return 1;
+ if(s1.s.equals(s2.s))
+ return 0;
+ return -1;
+ }
+ }
+ );
+ for(Sommet u : sommets()){
+ if(u.equals(s))
+ L.put(u, 0);
+ else if(existeArc(s, u)){
+ int val = valeurArc(s, u);
+ fp.add(new SommetValue(u, val));
+ L.put(u, val);
+ }
+ else{
+ fp.add(new SommetValue(u, INFINITY));
+ L.put(u, INFINITY);
+ }
+ }
+ return fp;
+ }
+
+ public HashMap Dijkstra2(T s){
+ HashMap L = new HashMap();
+
+ // 1. initialisation
+ TreeSet U = Dijkstra2Init(L, s);
+ // 3.
+ while(! U.isEmpty()){
+ //afficherParcours(L);
+ // 4.
+ SommetValue v = U.first();
+ U.remove(v);
+ int Lv = v.valeur;
+ //System.err.println("v="+v.s+" Lv="+Lv);
+ // 5.
+ // 6.
+ for(Arc a : voisins(v.s)){
+ Sommet t = a.destination();
+ int tmp = Lv + a.valeur();
+ if(tmp < L.get(t)){
+ // System.err.println("-"+t+" "+L.get(t));
+ U.remove(new SommetValue(t, L.get(t)));
+ // System.err.println("+"+t+" "+tmp);
+ U.add(new SommetValue(t, tmp));
+ L.put(t, tmp);
+ }
+ }
+ }
+ return L;
+ }
+
+ public void Prim(){
+ HashSet HS = new HashSet();
+ for(Sommet u : sommets()){
+ if(! HS.contains(u)){
+ //System.err.println("Je pars de "+u);
+ HS.add(u);
+ TreeSet> fp =
+ new TreeSet>(
+ new Comparator>(){
+ public int compare(Arc a1, Arc a2){
+ if(a1.valeur() < a2.valeur())
+ return -1;
+ else if(a1.valeur() > a2.valeur())
+ return 1;
+ else if(a1.equals(a2))
+ return 0;
+ else if(! a1.origine().equals(a2.origine()))
+ return a1.origine().compareTo(a2.origine());
+ else if(! a1.destination().equals(a2.destination()))
+ return a1.destination().compareTo(a2.destination());
+ else
+ return 0;
+ }
+ }
+ );
+ for(Arc a : voisins(u)){
+ //System.err.println("fp += "+a+" ["+a.valeur()+"]");
+ fp.add(a);
+ }
+ while(! fp.isEmpty()){
+ System.err.println("FP_BEGIN");
+ for(Arc z : fp){
+ System.err.println(z+" "+z.valeur());
+ }
+ System.err.println("FP_END");
+ Arc a = fp.first();
+ fp.remove(a);
+ Sommet t = a.destination();
+ System.err.print("Je regarde "+a+"["+a.valeur()+"] : ");
+ if(HS.contains(t))
+ System.err.println("il forme un cycle");
+ else{
+ System.err.println("je l'ajoute dans T");
+ HS.add(t);
+ for(Arc b : voisins(t)){
+ System.err.println("fp += "+b+" ["+b.valeur()+"]");
+ fp.add(b);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //////////////////// BFS ////////////////////
+
+
+ final static int inexplore = 0, encours = 1, explore = 2;
+
+ public void bfs(HashMap etat, Sommet s){
+ LinkedList f = new LinkedList();
+
+ etat.put(s, encours);
+ f.addLast(s);
+ while(! f.isEmpty()){
+ Sommet t = f.removeFirst();
+ System.err.println("J'explore "+t);
+ for(Arc a : voisins(t)){
+ Sommet u = a.destination();
+ if(etat.get(u) == inexplore){
+ etat.put(u, encours);
+ f.addLast(u);
+ }
+ }
+ etat.put(t, explore);
+ }
+ }
+
+ public HashMap bfsDistance(Sommet s){
+ HashMap etat = new HashMap();
+ LinkedList f = new LinkedList();
+ HashMap distance =
+ new HashMap();
+ HashMap numero =
+ new HashMap();
+ int num = 0;
+
+ for(Sommet t : sommets()){
+ etat.put(t, inexplore);
+ distance.put(t, 0);
+ numero.put(t, 0);
+ }
+ etat.put(s, encours);
+ f.addLast(s);
+ numero.put(s, num++);
+ while(! f.isEmpty()){
+ Sommet t = f.removeFirst();
+ System.err.println("J'explore "+t);
+ for(Arc a : voisins(t)){
+ Sommet u = a.destination();
+ if(etat.get(u) == inexplore){
+ etat.put(u, encours);
+ f.addLast(u);
+ numero.put(u, num++);
+ System.err.println("num["+u+"]="+numero.get(u));
+ distance.put(u, distance.get(t) + 1);
+ }
+ }
+ etat.put(t, explore);
+ }
+ return distance;
+ }
+
+ public void composantesConnexesBFS(){
+ HashMap etat = new HashMap();
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ int ncc = 0;
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore){
+ ncc++;
+ System.err.println("Composante "+ncc);
+ bfs(etat, s);
+ }
+ }
+
+ public boolean bfsBiparti(HashMap etat, HashMap couleur, Sommet s){
+ LinkedList f = new LinkedList();
+ int c = 0; // la couleur
+
+ etat.put(s, encours);
+ couleur.put(s, c);
+ f.addLast(s);
+ while(! f.isEmpty()){
+ Sommet t = f.removeFirst();
+ System.err.println("J'explore "+t+" de couleur "+couleur.get(t));
+ // c <- couleur des voisins de t
+ c = 1 - couleur.get(t);
+ for(Arc a : voisins(t)){
+ Sommet u = a.destination();
+ if(etat.get(u) == inexplore){
+ etat.put(u, encours);
+ couleur.put(u, c);
+ f.addLast(u);
+ }
+ else if(couleur.get(u) != c){
+ System.err.println(u+" est de'ja` colorie' avec la mauvaise couleur");
+ return false;
+ }
+ }
+ etat.put(t, explore);
+ }
+ return true;
+ }
+
+ // n'a vraiment un sens que sur les graphes non oriente's connexes
+ public HashMap estBiparti(){
+ HashMap etat = new HashMap();
+ HashMap couleur = new HashMap();
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ int ncc = 0;
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore){
+ ncc++;
+ System.err.println("Composante "+ncc);
+ if(!bfsBiparti(etat, couleur, s))
+ // le graphe n'est pas biparti
+ return null;
+ }
+ return couleur;
+ }
+
+////////////DFS
+
+ public void dfs(HashMap etat, Sommet s){
+ LinkedList F = new LinkedList();
+ int rg = -1;
+
+ F.addFirst(s);
+ while(! F.isEmpty()){
+ Sommet t = F.removeFirst();
+ if(etat.get(t) != explore){
+ System.err.println("J'explore "+t);
+ etat.put(t, encours);
+ ++rg;
+ System.err.println("rang["+t+"]="+rg);
+ for(Arc a : voisins(t)){
+ Sommet u = a.destination();
+ F.addFirst(u);
+ }
+ }
+ etat.put(t, explore);
+ }
+ }
+
+ public void dfs(){
+ Sommet r = null;
+ for(Sommet s : sommets()){
+ r = s;
+ break;
+ }
+ HashMap etat = new HashMap();
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ //dfsFausse(etat, r); // pour avoir un exemple qui foire Data/pchassignet.in
+ dfs(etat, r);
+ }
+
+ public int dfsRec(HashMap etat,
+ HashMap,String> etat_a,
+ HashMap rang, int rg,
+ Sommet racine, Sommet s){
+ etat.put(s, encours);
+ rang.put(s, rg++);
+ System.err.println("J'explore "+s);
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat.get(t) == inexplore){
+ System.err.println("("+s+", "+t+") liaison");
+ etat_a.put(a, "arcliaison");
+ rg = dfsRec(etat, etat_a, rang, rg, racine, t);
+ }
+ else{
+ if(etat.get(t) == encours){
+ // t est ascendant de s
+ System.err.println("("+s+", "+t+") arrie`re");
+ etat_a.put(a, "arcarriere");
+ }
+ else{
+ // t a de'ja` e'te' explore'
+ if(rang.get(t) < rang.get(racine)){
+ System.err.println("("+s+", "+t+") transverse car racine("+t+") <> racine("+s+")");
+ etat_a.put(a, "arcinter");
+ }
+ else{ // t est dans la me^me arborescence que s
+ if(rang.get(s) < rang.get(t)){
+ System.err.println("("+s+", "+t+") avant");
+ etat_a.put(a, "arcavant");
+ }
+ else{
+ System.err.println("("+s+", "+t+") transverse");
+ etat_a.put(a, "arcintra");
+ }
+ }
+ }
+ }
+ }
+ etat.put(s, explore);
+ return rg;
+ }
+
+ public void dfsRang(){
+ HashMap etat = new HashMap();
+ HashMap,String> etat_a = new HashMap,String>();
+ HashMap rang = new HashMap();
+
+ for(Sommet s : sommets()){
+ etat.put(s, inexplore);
+ for(Arc alpha : voisins(s))
+ etat_a.put(alpha, "arclibre");
+ }
+ int rg = 0;
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore)
+ rg = dfsRec(etat, etat_a, rang, rg, s, s);
+ System.err.print(" ");
+ for(Sommet t : sommets())
+ System.err.print(t);
+ System.err.print("\nrang ");
+ for(Sommet t : sommets())
+ System.err.print(rang.get(t));
+ System.err.println();
+ }
+
+ // on retourne un arbre couvrant de racine s
+ public Arbre dfsRec(HashMap etat, Sommet s){
+ etat.put(s, encours);
+ Arbre A = new Arbre(s);
+ System.err.println("J'explore "+s);
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat.get(t) == inexplore)
+ A.ajouterFils(dfsRec(etat, t));
+ }
+ etat.put(s, explore);
+ return A;
+ }
+
+ public void dfsCouvrant(){
+ Sommet ALPHA = new Sommet("ALPHA");
+ Arbre F = new Arbre(ALPHA);
+ HashMap etat = new HashMap();
+
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore)
+ F.ajouterFils(dfsRec(etat, s));
+ System.err.println("F=\n"+F);
+ }
+
+ //// Tri topologique
+
+ boolean dfsTopo(HashMap etat,
+ LinkedList L, Sommet s){
+ etat.put(s, encours);
+ System.err.println("J'explore "+s);
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat.get(t) == inexplore){
+ if(! dfsTopo(etat, L, t))
+ return false;
+ }
+ else if(etat.get(t) == encours){
+ // t est ascendant de s
+ System.err.println("("+s+", "+t+") arrie`re -> erreur");
+ return false;
+ }
+ }
+ etat.put(s, explore);
+ L.addFirst(s);
+ return true;
+ }
+
+ public void triTopologique(){
+ HashMap etat = new HashMap();
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ for(Sommet s : sommets()){
+ if(etat.get(s) == inexplore){
+ LinkedList L = new LinkedList();
+ if(! dfsTopo(etat, L, s)){
+ System.err.println("Graphe avec circuit");
+ return;
+ }
+ for(Sommet t : L)
+ System.err.print(t+" -> ");
+ System.err.println();
+ }
+ }
+ }
+
+ //// Points d'attache
+ int dfsAttache(HashMap etat,
+ HashMap rang, int rg,
+ HashMap rat, Sommet racine, Sommet s){
+ etat.put(s, encours);
+ System.err.println("J'explore "+s);
+ rang.put(s, rg++);
+ int rats = rang.get(s), ratt;
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat.get(t) == inexplore){
+ rg = dfsAttache(etat, rang, rg, rat, racine, t);
+ ratt = rat.get(t);
+ }
+ else if(etat.get(t) == encours)
+ // (s, t) est un arc arrie`re
+ ratt = rang.get(t);
+ else if(rang.get(t) < rang.get(racine))
+ // (s, t) transverse inter
+ continue;
+ else // (s, t) avant ou transverse intra
+ ratt = rang.get(t);
+ // HERE: vrai? Cf. exemple bbc1 pour l semble faux...!
+ rats = Math.min(rats, ratt);
+ }
+ rat.put(s, rats);
+ etat.put(s, explore);
+ return rg;
+ }
+
+ public void pointsDAttache(){
+ HashMap etat = new HashMap();
+ HashMap rang = new HashMap();
+ HashMap rat = new HashMap();
+
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ int rg = 0;
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore)
+ rg = dfsAttache(etat, rang, rg, rat, s, s);
+ System.err.println("Rangs");
+ for(Sommet s : sommets())
+ System.err.println(s+" "+rang.get(s));
+ System.err.println("Rangs d'attache");
+ for(Sommet s : sommets())
+ System.err.println(s+" "+rat.get(s));
+ }
+
+ //// Composantes fortement connexes
+
+ final static int libre = 0, empile = 1, exclus = 2, pointdentree = 3, dansCFC = 4;
+
+ int dfsCfc(HashMap etat,
+ HashMap etat_cfc,
+ HashMap,String> etat_a,
+ LinkedList pile,
+ HashMap rang, int rg,
+ HashMap rat,
+ Sommet racine, Sommet s){
+ etat.put(s, encours);
+ System.err.println("J'explore "+s);
+ rang.put(s, rg++);
+ rat.put(s, rang.get(s));
+ pile.addFirst(s);
+ etat_cfc.put(s, empile);
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat_cfc.get(t) == inexplore){
+ System.err.println("("+s+", "+t+") liaison");
+ etat_a.put(a, "arcliaison");
+ rg = dfsCfc(etat, etat_cfc, etat_a, pile, rang, rg, rat, racine, t);
+ if(rat.get(t) < rat.get(s)){
+ rat.put(s, rat.get(t));
+ }
+ }
+ else{
+ if(etat_cfc.get(t) == empile){
+ if(rang.get(t) > rang.get(s))
+ // (s, t) est avant
+ etat_a.put(a, "arcavant");
+ else{
+ // (s, t) est arriere ou intra-arbre
+ // t est dans C(s) car t descendant de s et s -> t
+ if(etat.get(t) == encours){
+ System.err.println("("+s+", "+t+") arrie`re");
+ etat_a.put(a, "arcarriere");
+ }
+ else{
+ System.err.println("("+s+", "+t+") intra-arbre");
+ etat_a.put(a, "arcintra");
+ }
+ System.err.println(t+" est dans C("+s+")");
+ if(rang.get(t) < rat.get(s))
+ rat.put(s, rang.get(t));
+ }
+ }
+ else{
+ // t est exclus
+ System.err.println(t+" exclus");
+ if(rang.get(t) < rang.get(racine))
+ // (s, t) est inter-arbre
+ etat_a.put(a, "arcinter");
+ else
+ etat_a.put(a, "arcintra");
+ }
+ }
+ }
+ etat.put(s, explore);
+ System.err.print("rang["+s+"]="+rang.get(s));
+ System.err.println(" rat["+s+"]="+rat.get(s));
+ if(rat.get(s) == rang.get(s)){
+ // s est un point d'entre'e
+ etat_cfc.put(s, pointdentree);
+ for(Sommet u : pile){
+ if(u.equals(s))
+ break;
+ etat_cfc.put(u, dansCFC);
+ }
+ Sommet t;
+ System.err.print("CFC={");
+ do{
+ t = pile.removeFirst();
+ etat_cfc.put(t, exclus);
+ System.err.print(" "+t);
+ } while(! t.equals(s));
+ System.err.println(" }");
+ }
+ return rg;
+ }
+
+ public void cfc(){
+ HashMap etat = new HashMap();
+ HashMap etat_cfc = new HashMap();
+ HashMap,String> etat_a = new HashMap, String>();
+ HashMap rang = new HashMap();
+ HashMap rat = new HashMap();
+ LinkedList pile = new LinkedList();
+
+ for(Sommet s : sommets()){
+ etat.put(s, inexplore);
+ etat_cfc.put(s, libre);
+ for(Arc alpha : voisins(s))
+ etat_a.put(alpha, "arclibre");
+ }
+ int rg = 0;
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore)
+ rg = dfsCfc(etat, etat_cfc, etat_a, pile, rang, rg, rat, s, s);
+ System.err.println("Rangs");
+ for(Sommet s : sommets())
+ System.err.println(s+" "+rang.get(s));
+ }
+
+ //// Points d'articulation et blocs
+
+ void depiler(LinkedList> pile, Sommet s, Sommet t){
+ Sommet x, y;
+ System.err.print("Bloc = {");
+ do{
+ Arc a = pile.removeFirst();
+ x = a.origine();
+ y = a.destination();
+ System.err.print("("+x+", "+y+")");
+ } while(!x.equals(s) && !y.equals(t));
+ System.err.println("}");
+ }
+
+ void depiler(LinkedList> pile){
+ System.err.print("Bloc_racine = {");
+ while(! pile.isEmpty()){
+ Arc a = pile.removeFirst();
+ System.err.print("("+a.origine()+", "+a.destination()+")");
+ }
+ System.err.println("}");
+ }
+
+ // pere -> s
+ int dfsPda(LinkedList lpda,
+ HashMap etat,
+ LinkedList> pile,
+ HashMap rang, int rg,
+ HashMap rat,
+ Sommet pere, Sommet s){
+ etat.put(s, encours);
+ System.err.println("J'explore "+s);
+ rang.put(s, rg++);
+ int rats = rang.get(s);
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat.get(t) == inexplore){
+ System.err.println("("+s+", "+t+") liaison");
+ pile.addFirst(a);
+ rg = dfsPda(lpda, etat, pile, rang, rg, rat, s, t);
+ rats = Math.min(rats, rat.get(t));
+ if(rat.get(t) >= rang.get(s)){
+ System.err.println(s+" est point d'articulation");
+ depiler(pile, s, t);
+ lpda.addFirst(s);
+ }
+ }
+ else if((rang.get(t) < rang.get(s)) && !t.equals(pere)){
+ System.err.println("("+s+", "+t+") arrie`re ou transverse");
+ pile.addFirst(a);
+ rats = Math.min(rats, rang.get(t));
+ }
+ }
+ rat.put(s, rats);
+ System.err.print("rang["+s+"]="+rang.get(s));
+ System.err.println(" rat["+s+"]="+rat.get(s));
+ etat.put(s, explore);
+ return rg;
+ }
+
+ // s est la racine de l'arborescence
+ int dfsPda(LinkedList lpda,
+ HashMap etat,
+ LinkedList> pile,
+ HashMap rang, int rg,
+ HashMap rat, Sommet s){
+ etat.put(s, encours);
+ System.err.println("J'explore "+s);
+ rang.put(s, rg++);
+ int rats = rang.get(s);
+ int nfils = 0;
+ for(Arc a : voisins(s)){
+ Sommet t = a.destination();
+ if(etat.get(t) == inexplore){
+ System.err.println("("+s+", "+t+") liaison");
+ pile.addFirst(a);
+ rg = dfsPda(lpda, etat, pile, rang, rg, rat, s, t);
+ nfils++;
+ }
+ }
+ if(nfils > 1){
+ lpda.addFirst(s);
+ System.err.println(s+" est racine ET point d'articulation");
+ depiler(pile);
+ }
+ rat.put(s, rats);
+ System.err.print("rang["+s+"]="+rang.get(s));
+ System.err.println(" rat["+s+"]="+rat.get(s));
+ etat.put(s, explore);
+ return rg;
+ }
+
+ public void pointsDArticulation(LinkedList lpda,
+ HashMap rat){
+ HashMap etat = new HashMap();
+ HashMap rang = new HashMap();
+
+ for(Sommet s : sommets())
+ etat.put(s, inexplore);
+ int rg = 0;
+ LinkedList> pile = new LinkedList>();
+ for(Sommet s : sommets())
+ if(etat.get(s) == inexplore)
+ // nouvelle composante connexe
+ rg = dfsPda(lpda, etat, pile, rang, rg, rat, s);
+ System.err.println("Rangs");
+ for(Sommet s : sommets())
+ System.err.println(s+" "+rang.get(s));
+ }
+
+ public static String XMLHeader(){
+ String str = "\n";
+ str += "\n";
+ str += " \n";
+ str += " 1.3.9\n";
+ str += " \n";
+ str += " \n";
+ str += " \n";
+ str += " \n";
+ str += " \n";
+ str += " \n";
+ return str;
+ }
+ public static String XMLTrailer(){
+ return "\n";
+ }
+ // pos[s] est la position de s dans le plan, color[s] le contenu de s, par exemple une couleur.
+ // pos[s] doit etre de la forme x,y
+ public String toGraphml(String nom, HashMap pos, HashMap color){
+ String str = XMLHeader();
+ str += " \n";
+ else
+ str += " edgedefault=\"undirected\">\n";
+ // les sommets
+ for(Sommet s : sommets()){
+ str += " \n";
+ if(pos != null)
+ str += " "+pos.get(s)+"\n";
+ if(color != null)
+ str += " " + color.get(s) + "\n";
+ str += " " + s + "\n";
+ str += " \n";
+ }
+ // les aretes
+ for(Sommet s : sommets()){
+ for(Arc arc : voisins(s)){
+ // TODO: permettre des couleurs et labels sur les arcs
+ Sommet t = arc.destination();
+ str += " \n";
+ str += " 1\n";
+ str += " 1\n";
+ str += " \n";
+ }
+ }
+ str += " \n";
+ str += XMLTrailer();
+ return str;
+ }*/
+}
+
diff --git a/src/designPattern/grapheX/GrapheGenerique.java b/src/designPattern/grapheX/GrapheGenerique.java
new file mode 100644
index 0000000..1b9df35
--- /dev/null
+++ b/src/designPattern/grapheX/GrapheGenerique.java
@@ -0,0 +1,81 @@
+package designPattern.grapheX;
+
+import java.util.Collection;
+
+/**
+ * Super-classe abstraite des graphes, les sommets doivent �tre identifiables.
+ *
+ * @author FMorain (morain@lix.polytechnique.fr)
+ * @author PChassignet (chassign@lix.polytechnique.fr)
+ * @version 2007.03.21
+ */
+
+public abstract class GrapheGenerique {
+
+ /**
+ * @return le nombre de sommets de ce graphe.
+ */
+ public abstract int taille();
+
+ /**
+ * @param s
+ * le sommet � ajouter � ce graphe.
+ */
+ public abstract void ajouterSommet(S s);
+
+ /**
+ * @return une Collection de tous les sommets de ce graphe.
+ */
+ public abstract Collection sommets();
+
+ /**
+ * Teste l'existence de l'arc de s � t dans ce graphe.
+ *
+ * @param s
+ * l'origine de l'arc,
+ * @param t
+ * l'extr�mit� de l'arc.
+ */
+ public abstract boolean existeArc(S s, S t);
+
+ /**
+ * @param s
+ * l'origine de l'arc,
+ * @param t
+ * l'extr�mit� de l'arc,
+ * @param val
+ * une valeur enti�re attach�e � l'arc de s � t
+ * dans ce graphe.
+ */
+ public abstract void ajouterArc(S s, S t, int val);
+
+ /**
+ * @param s
+ * l'origine de l'arc,
+ * @param t
+ * l'extr�mit� de l'arc.
+ * @return la valeur enti�re attach�e � l'arc de s � t
+ * dans ce graphe.
+ */
+ public abstract int valeurArc(S s, S t);
+
+ /**
+ * Supprime l'arc de s � t dans ce graphe.
+ *
+ * @param s
+ * l'origine de l'arc,
+ * @param t
+ * l'extr�mit� de l'arc.
+ */
+ public abstract void enleverArc(S s, S t);
+
+ /**
+ * @param s
+ * l'origine des arcs.
+ * @return une Collection de tous les arcs de ce graphe ayant
+ * s pour origine. Ces arcs sont de type
+ * Arc<S>.
+ */
+ public abstract Collection> voisins(S s);
+
+}
diff --git a/src/designPattern/grapheX/Identifiable.java b/src/designPattern/grapheX/Identifiable.java
new file mode 100644
index 0000000..603d30e
--- /dev/null
+++ b/src/designPattern/grapheX/Identifiable.java
@@ -0,0 +1,100 @@
+package designPattern.grapheX;
+
+/**
+ * D�finit des objets identifi�s par une String. Deux objets
+ * Identifiable qui sont construit avec le m�me identifiant seront
+ * consid�r�s comme identiques pour les m�thodes hashCode,
+ * equals et compareTo. Cette classe sert notamment de
+ * super-classe pour les sommets d'un graphe.
+ *
+ * @author PChassignet (chassign@lix.polytechnique.fr)
+ * @version 2007.03.21
+ */
+
+public class Identifiable implements Comparable {
+ private final String ident;
+
+ /**
+ * @param identifiant
+ * l'identifiant pour cet objet.
+ */
+ public Identifiable(String identifiant) {
+ ident = identifiant;
+ }
+
+ /**
+ * @return l'identifiant pour cet objet.
+ */
+ public final String identifiant() {
+ return ident;
+ }
+
+ /**
+ * @return le hashCode de l'identifiant de cet objet.
+ */
+ @Override
+public final int hashCode() {
+ if (ident == null)
+ return 0;
+ else
+ return ident.hashCode();
+ }
+
+ /**
+ * @return le r�sultat de equals sur les identifiants.
+ */
+ @Override
+public final boolean equals(Object o) {
+ if (!(o instanceof Identifiable)) {
+ return false;
+ }
+ String oid = ((Identifiable) o).ident;
+ if (ident == null)
+ return oid == null;
+ else
+ return ident.equals(oid);
+ }
+
+ /**
+ * @return le r�sultat de compareTo sur les identifiants.
+ */
+public final int compareTo(Identifiable id) {
+ if (ident == null)
+ if (id.ident == null)
+ return 0;
+ else
+ return -1;
+ else if (id.ident == null)
+ return 1;
+ else
+ return ident.compareTo(id.ident);
+ }
+
+ /**
+ * @param id1
+ * premier objet � comparer,
+ * @param id2
+ * second objet � comparer,
+ * @return le r�sultat de id1.compareTo(id2).
+ */
+ public static final int compare(Identifiable id1, Identifiable id2) {
+ if (id1 == null)
+ if (id2 == null)
+ return 0;
+ else
+ return -1;
+ else if (id2 == null)
+ return 1;
+ else
+ return id1.compareTo(id2);
+ }
+
+ @Override
+public String toString() {
+ if (ident == null)
+ return "[null]";
+ else
+ return "[\"" + ident + "\"]";
+ }
+
+}
diff --git a/src/designPattern/grapheX/Sommet.java b/src/designPattern/grapheX/Sommet.java
new file mode 100644
index 0000000..2048e5a
--- /dev/null
+++ b/src/designPattern/grapheX/Sommet.java
@@ -0,0 +1,23 @@
+package designPattern.grapheX;
+
+/**
+ * Classe de sommets, toutes les propri�t�s sont h�rit�es de Identifiable.
+ *
+ * @author FMorain (morain@lix.polytechnique.fr)
+ * @author PChassignet (chassign@lix.polytechnique.fr)
+ * @version 2007.03.21
+ */
+
+public class Sommet extends Identifiable {
+
+ public Sommet(String nn) {
+ super(nn);
+ }
+
+ @Override
+public String toString() {
+ return identifiant();
+ }
+
+
+}
diff --git a/src/designPattern/grapheX/SommetValue.java b/src/designPattern/grapheX/SommetValue.java
new file mode 100644
index 0000000..2dfba10
--- /dev/null
+++ b/src/designPattern/grapheX/SommetValue.java
@@ -0,0 +1,11 @@
+package designPattern.grapheX;
+
+public class SommetValue {
+ Sommet s;
+ int valeur;
+
+ SommetValue(Sommet ss, int vv){
+ s = ss;
+ valeur = vv;
+ }
+}
diff --git a/src/designPattern/reseauSocial/core/Member.java b/src/designPattern/reseauSocial/core/Member.java
new file mode 100644
index 0000000..895531b
--- /dev/null
+++ b/src/designPattern/reseauSocial/core/Member.java
@@ -0,0 +1,44 @@
+package designPattern.reseauSocial.core;
+
+import designPattern.grapheX.Sommet;
+
+public class Member extends Sommet implements MemberInterface {
+
+ private String localisation;
+ private Enum force;
+
+ public Member(String nn) {
+ super(nn);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public String getLocation() {
+ return this.localisation;
+ }
+
+ @Override
+ public void setLocation(String s) {
+ this.localisation = s;
+ }
+
+ @Override
+ public String getName() {
+ return super.toString();
+ }
+
+ public Enum getForce() {
+ return force;
+ }
+
+ public void setForce(Enum force) {
+ this.force = force;
+ }
+
+ public void addMember(String nom, String location, SocialNetworkInterface reseau) {
+ Member m = new Member(nom);
+ m.setLocation(location);
+ reseau.addMember(m);
+ }
+
+}
diff --git a/src/designPattern/reseauSocial/core/MemberInterface.java b/src/designPattern/reseauSocial/core/MemberInterface.java
new file mode 100755
index 0000000..1416c5d
--- /dev/null
+++ b/src/designPattern/reseauSocial/core/MemberInterface.java
@@ -0,0 +1,10 @@
+package designPattern.reseauSocial.core;
+
+public interface MemberInterface {
+
+
+ public String getLocation();
+ public void setLocation(String s);
+
+ public String getName();
+}
diff --git a/src/designPattern/reseauSocial/core/SocialNetWorkImpl.java b/src/designPattern/reseauSocial/core/SocialNetWorkImpl.java
new file mode 100644
index 0000000..3e0be47
--- /dev/null
+++ b/src/designPattern/reseauSocial/core/SocialNetWorkImpl.java
@@ -0,0 +1,85 @@
+package designPattern.reseauSocial.core;
+
+import java.util.Collection;
+import java.util.Observable;
+import java.util.Set;
+
+import designPattern.facebookGhost.FacebookGhostNetwork;
+import designPattern.grapheSimple.GrapheSimple;
+
+@SuppressWarnings("deprecation")
+public class SocialNetWorkImpl implements SocialNetworkInterface{
+
+ private String nom;
+ private GrapheSimple reseau;
+
+ public SocialNetWorkImpl() {
+ this("Default");
+ }
+
+ public SocialNetWorkImpl(String n) {
+ this.nom = n;
+ reseau = new GrapheSimple();
+ }
+
+ @Override
+ public void update(Observable arg0, Object arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Member getMember(String identifier) {
+ return reseau.getSommet(identifier);
+ }
+
+ @Override
+ public Collection getMembers() {
+ return reseau.sommets();
+ }
+
+ @Override
+ public void addMember(Member m) {
+ reseau.ajouterSommet(m);
+ }
+
+ @Override
+ public Member addMember(String ident, FacebookGhostNetwork fg) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Member addMember(String identifier) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void relate(Strength force, Member member, Member friend) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Set relatedToRank(Member member, int rank) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int distance(Member member1, Member member2) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String getNom() {
+ return nom;
+ }
+
+ public void setNom(String n) {
+ this.nom = n;
+ }
+
+
+}
diff --git a/src/designPattern/reseauSocial/core/SocialNetworkInterface.java b/src/designPattern/reseauSocial/core/SocialNetworkInterface.java
new file mode 100755
index 0000000..ec4101c
--- /dev/null
+++ b/src/designPattern/reseauSocial/core/SocialNetworkInterface.java
@@ -0,0 +1,74 @@
+package designPattern.reseauSocial.core;
+
+
+import java.util.Collection;
+import java.util.Observer;
+import java.util.Set;
+
+import designPattern.facebookGhost.FacebookGhostNetwork;
+
+/**
+ *
+ * Basic" interface for defining a social network
+ *
+ * @author blay
+ *
+ */
+
+@SuppressWarnings("deprecation")
+public interface SocialNetworkInterface extends Observer{
+
+ /**
+ * @param identifier for a member
+ * @return member if known by the network
+ */
+ public T getMember(String identifier);
+
+ /**
+ * @return the set of members belonging to the network
+ */
+ public Collection getMembers();
+
+ /**
+ * add a member to the network
+ */
+ public void addMember(T membre);
+
+ /**
+ * @param ident
+ * @param fg a facebookGhostNetwork, if the member belongs to fg, an adapter to this network is created.
+ * @return the member corresponding to the identifier. If a member with this identifer already exists, the member is not created.
+ */
+ public T addMember(String ident, FacebookGhostNetwork fg);
+ public T addMember(String identifier);
+
+
+ /**
+ *
+ * Add the relationship between a member and a friend with a given force.
+ *
+ * @param force
+ * @param member
+ * @param friend
+ *
+ */
+ public void relate(Strength force, T member, T friend);
+
+ /**
+ * @param member
+ * @param rank
+ * @return returns all members given the rank (at rank 1 : direct neighbors; at rank 2 : neighbors of neighbors.
+ * A member appears at the lowest rank, it does not appear in a higher rank
+ */
+ public Set relatedToRank(T member, int rank);
+
+ /**
+ * @param member1
+ * @param member2
+ * @return distance between the two members
+ */
+ public int distance(T member1, T member2);
+
+
+
+}
diff --git a/src/designPattern/reseauSocial/core/Strength.java b/src/designPattern/reseauSocial/core/Strength.java
new file mode 100755
index 0000000..9835d50
--- /dev/null
+++ b/src/designPattern/reseauSocial/core/Strength.java
@@ -0,0 +1,17 @@
+package designPattern.reseauSocial.core;
+
+public enum Strength {
+ LOW (4), MEDIUM (3), HIGH (2), STRONG(1);
+
+ int value;
+
+ public int getValue() {
+ return value;
+ }
+
+ Strength( int pvalue){
+ value = pvalue;
+ }
+
+
+}
diff --git a/src/forum/Administrateur.java b/src/forum/Administrateur.java
new file mode 100755
index 0000000..6e14ba6
--- /dev/null
+++ b/src/forum/Administrateur.java
@@ -0,0 +1,15 @@
+package forum;
+
+public class Administrateur {
+
+ private String nom;
+
+ public Administrateur() {
+
+ }
+
+ public Administrateur(String nomAdmin) {
+ this.nom = nomAdmin;
+ }
+
+}
\ No newline at end of file
diff --git a/src/forum/Canal.java b/src/forum/Canal.java
new file mode 100755
index 0000000..57bb469
--- /dev/null
+++ b/src/forum/Canal.java
@@ -0,0 +1,17 @@
+package forum;
+
+import java.util.ArrayList;
+
+public class Canal {
+
+ private int maxMessage;
+ private String nomCanal;
+ private Message message;
+ ArrayList canal = new ArrayList();
+
+ public Canal(String nomCanal, int maxMessage) {
+ this.nomCanal = nomCanal;
+ this.maxMessage = maxMessage;
+ }
+
+}
diff --git a/src/forum/CanalDeBreve.java b/src/forum/CanalDeBreve.java
new file mode 100755
index 0000000..a2000aa
--- /dev/null
+++ b/src/forum/CanalDeBreve.java
@@ -0,0 +1,14 @@
+package forum;
+
+public class CanalDeBreve {
+
+ private int tailleBreves;
+ private String nomCanal;
+ private Message message;
+
+ public CanalDeBreve(String nomCanal, int tailleBreves) {
+ this.nomCanal = nomCanal;
+ this.tailleBreves = tailleBreves;
+ }
+
+}
diff --git a/src/forum/CanalParDefaut.java b/src/forum/CanalParDefaut.java
new file mode 100755
index 0000000..61fd710
--- /dev/null
+++ b/src/forum/CanalParDefaut.java
@@ -0,0 +1,9 @@
+package forum;
+
+public class CanalParDefaut {
+ public String nom;
+
+ public CanalParDefaut(String nom) {
+ }
+
+}
diff --git a/src/forum/Controleur.java b/src/forum/Controleur.java
new file mode 100755
index 0000000..d5f07f4
--- /dev/null
+++ b/src/forum/Controleur.java
@@ -0,0 +1,88 @@
+package forum;
+
+public class Controleur {
+
+ private GestionnaireForum registreF = new GestionnaireForum();
+ private GestionnaireCanal registreC = new GestionnaireCanal();
+ private UserConsole ui = new UserConsole();
+
+ public void start() throws Exception {
+ String commande = ui.lireCommande();
+ switch (commande.charAt(0)) {
+ case UserConsole.COM_CREER_FORUM:
+ creerForum();
+ start();
+ break;
+ case UserConsole.COM_CREER_CANAL:
+ creerCanal();
+ start();
+ break;
+ case UserConsole.COM_POSTER_MESSAGES:
+// posterMessage();
+ start();
+ break;
+ case UserConsole.COM_LIRE_MESSAGES:
+// lireMessage();
+ start();
+ break;
+ case UserConsole.COM_STOP:
+ ui.afficher("Au revoir ");
+ // Memoire.save(registre, "sauvegarde.txt");
+ System.exit(0);
+ break;
+ default:
+ ui.afficher("La commande spécifiée n'existe pas\n");
+ Thread.sleep(1000);
+ start();
+ }
+ }
+
+ private void creerForum() {
+ String nomForum = ui.getValeur("Nom du forum :");
+ registreF.addForum(nomForum);
+
+ }
+
+ private void creerCanal() {
+ String nomForum = ui.getValeur("Entrer le nom du forum dans lequel vous voulez créer un canal :");
+ while (!GestionnaireForum.doesExist(nomForum)) {
+ System.out.println("Erreur : Il n'y a aucun forum de ce nom.");
+ nomForum = ui.getValeur("Entrer le nom du forum dans lequel vous voulez créer un canal :");
+ }
+
+ String typeCanal;
+ System.out.println("Quel type de canal voulez-vous créer ?");
+ typeCanal = ui.getValeur("Entrer \"c\" pour canal ou \"b\" pour canal de brèves");
+ while (!(typeCanal.contentEquals("c") || typeCanal.contentEquals("b"))) {
+ System.out.println("Erreur : donnée invalide.");
+ typeCanal = ui.getValeur("Quel type de canal voulez-vous créer ?");
+ }
+
+ String nomCanal = ui.getValeur("Entrer le nom du canal");
+
+ if (typeCanal.contentEquals("c")) {
+ System.out.println("Voulez-vous changer le nombre de messages max possibles pour ce canal?");
+ String nb = ui.getValeur("Répondre y pour oui, n pour non");
+ try {
+ int maxMessage = Integer.parseInt(nb);
+ registreC.CreerCanal(nomCanal, maxMessage);
+ } catch (NumberFormatException nfe) {
+ System.out.println("Erreur, ce n'est pas un entier");
+ }
+ } else {
+ String nb = ui.getValeur("Quelle taille max voulez-vous pour les brèves?");
+ try {
+ int tailleBreve = Integer.parseInt(nb);
+ registreC.CreerCanalDeBreve(nomCanal, tailleBreve);
+ } catch (NumberFormatException nfe) {
+ System.out.println("Erreur, ce n'est pas un entier");
+ }
+ }
+
+ }
+
+ public static void main(String[] args) throws Exception {
+ Controleur c = new Controleur();
+ c.start();
+ }
+}
\ No newline at end of file
diff --git a/src/forum/Forum.java b/src/forum/Forum.java
new file mode 100755
index 0000000..7ddbf90
--- /dev/null
+++ b/src/forum/Forum.java
@@ -0,0 +1,17 @@
+package forum;
+
+public class Forum {
+
+ private String title;
+ private CanalParDefaut defaultCanal;
+
+ public Forum(String nomForum) {
+ this.title = nomForum;
+ this.defaultCanal = new CanalParDefaut("defaut");
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+}
diff --git a/src/forum/GestionnaireCanal.java b/src/forum/GestionnaireCanal.java
new file mode 100755
index 0000000..2822698
--- /dev/null
+++ b/src/forum/GestionnaireCanal.java
@@ -0,0 +1,26 @@
+package forum;
+
+import java.util.HashMap;
+
+public class GestionnaireCanal {
+
+ private static HashMap