Initial commit

This commit is contained in:
aminecmi 2014-10-03 15:34:03 +02:00
commit 9e71bf4114
21 changed files with 418 additions and 0 deletions

1
.idea/.name generated Normal file
View File

@ -0,0 +1 @@
LesSyms4

23
.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

3
.idea/copyright/profiles_settings.xml generated Normal file
View File

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

5
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

11
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="IdProvider" IDEtalkID="5EBAA9F33699B0593DE250C306D65C2A" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

9
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/LesSyms4.iml" filepath="$PROJECT_DIR$/LesSyms4.iml" />
</modules>
</component>
</project>

5
.idea/scopes/scope_settings.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

125
.idea/uiDesigner.xml generated Normal file
View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

8
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

12
LesSyms4.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,8 @@
package Comportements;
public class ComportementAPiedAvecHache implements ComportementCombat {
@Override
public String combattre() {
return "Par ma hache !";
}
}

View File

@ -0,0 +1,5 @@
package Comportements;
public interface ComportementCombat {
String combattre();
}

View File

@ -0,0 +1,8 @@
package Comportements;
public class ComportementCombatAvecCheval implements ComportementCombat {
@Override
public String combattre() {
return "Huu ! Attaque";
}
}

View File

@ -0,0 +1,9 @@
package Comportements;
public class ComportementCrier implements ComportementEmmetreSon {
@Override
public String emmetreSon() {
return "Bwaaaaaa";
}
}

View File

@ -0,0 +1,5 @@
package Comportements;
public interface ComportementEmmetreSon {
public String emmetreSon();
}

View File

@ -0,0 +1,10 @@
package Comportements;
public class ComportementParlerCommeUnePrincesse implements ComportementEmmetreSon {
@Override
public String emmetreSon() {
return "La la la la la";
}
}

19
src/Person/Chevalier.java Normal file
View File

@ -0,0 +1,19 @@
package Person;
import Comportements.ComportementCrier;
import Comportements.ComportementCombatAvecCheval;
public class Chevalier extends Personnage {
public Chevalier(String nom) {
super(nom);
this.comportementCombat = new ComportementCombatAvecCheval();
this.comportementEmmetreSon = new ComportementCrier();
}
public String getNom() {
return "Chevalier " + this.nom + " à votre service";
}
}

View File

@ -0,0 +1,17 @@
package Person;
import Comportements.ComportementAPiedAvecHache;
import Comportements.ComportementCrier;
public class Fantasssin extends Personnage {
public Fantasssin(String nom) {
super(nom);
this.comportementCombat = new ComportementAPiedAvecHache();
this.comportementEmmetreSon = new ComportementCrier();
}
@Override
public String getNom() {
return "Seraffin " + this.nom + ". A vos ordres";
}
}

View File

@ -0,0 +1,42 @@
package Person;
import Comportements.ComportementCombat;
import Comportements.ComportementEmmetreSon;
public abstract class Personnage {
protected String nom;
protected ComportementCombat comportementCombat;
protected ComportementEmmetreSon comportementEmmetreSon;
protected Personnage(String nom) {
this.nom = nom;
this.comportementCombat = null;
this.comportementEmmetreSon = null;
}
public abstract String getNom();
public void setComportementCombat(ComportementCombat comportementCombat) {
this.comportementCombat = comportementCombat;
}
public void setComportementEmmetreSon(ComportementEmmetreSon comportementEmmetreSon) {
this.comportementEmmetreSon = comportementEmmetreSon;
}
public ComportementEmmetreSon getComportementEmmetreSon() {
return comportementEmmetreSon;
}
public String EmmetreSon() {
return this.comportementEmmetreSon.emmetreSon();
}
public String Combattre() {
if (this.comportementCombat != null)
return this.comportementCombat.combattre();
else {
return "Ohhh, je suis trop faible pour combattre !";
}
}
}

17
src/Person/Princesse.java Normal file
View File

@ -0,0 +1,17 @@
package Person;
import Comportements.ComportementParlerCommeUnePrincesse;
public class Princesse extends Personnage {
public Princesse(String nom) {
super(nom);
this.comportementEmmetreSon = new ComportementParlerCommeUnePrincesse();
}
@Override
public String getNom() {
return "Je suis " + this.nom + " princesse des princesses";
}
}

76
src/SimulationJeu.java Normal file
View File

@ -0,0 +1,76 @@
import Comportements.ComportementAPiedAvecHache;
import Comportements.ComportementCombat;
import Comportements.ComportementEmmetreSon;
import Comportements.ComportementParlerCommeUnePrincesse;
import Person.Chevalier;
import Person.Fantasssin;
import Person.Personnage;
import Person.Princesse;
import java.util.ArrayList;
public class SimulationJeu {
ArrayList<Personnage> liste;
public SimulationJeu() {
liste = new ArrayList<Personnage>();
}
public String afficheTous() {
StringBuilder result = new StringBuilder();
for(Personnage p: liste) {
result.append(p.getNom());
result.append(System.getProperty("line.separator"));
}
return result.toString();
}
public void changerComportementCombat(Personnage p, ComportementCombat c){
p.setComportementCombat(c);
}
public void changerComportementEmmetreSon(Personnage p, ComportementEmmetreSon c){
p.setComportementEmmetreSon(c);
}
public void creationPersonnages() {
Princesse p = new Princesse("Fiona");
Chevalier z = new Chevalier("Zodiac");
Fantasssin f = new Fantasssin("Fantastic");
liste.add(p);
liste.add(z);
liste.add(f);
}
public String emmetreUnSonTous() {
StringBuilder result = new StringBuilder();
for (Personnage p: liste) {
result.append(p.EmmetreSon());
result.append(System.getProperty("line.separator"));
}
return result.toString();
}
public String lancerCombar() {
StringBuilder result = new StringBuilder();
for (Personnage p: liste) {
result.append(p.Combattre());
result.append(System.getProperty("line.separator"));
}
return result.toString();
}
public static void main(String[] args){
SimulationJeu s = new SimulationJeu();
s.creationPersonnages();
System.out.println(s.afficheTous());
System.out.println(s.emmetreUnSonTous());
System.out.println(s.lancerCombar());
s.changerComportementCombat(s.liste.get(0), new ComportementAPiedAvecHache());
s.changerComportementEmmetreSon(s.liste.get(0), new ComportementParlerCommeUnePrincesse());
System.out.println(s.emmetreUnSonTous());
System.out.println(s.lancerCombar());
}
}