objet et decorateur

This commit is contained in:
CCAZOT 2015-01-22 19:08:47 +01:00
parent a795db4f6e
commit 2e1eafcc77
16 changed files with 220 additions and 59 deletions

5
src/Etats/EEtat.java Normal file
View File

@ -0,0 +1,5 @@
package Etats;
public enum EEtat {
EtatOK,EtatKO
}

View File

@ -1,5 +1,12 @@
package Etats;
public abstract class EtatPersonnageAbstrait {
import Person.Personnage;
public abstract class EtatPersonnageAbstrait {
protected Personnage joueur;
protected EtatPersonnageAbstrait(Personnage perso){
this.joueur = perso;
}
}

View File

@ -1,5 +1,12 @@
package Etats;
import Person.Personnage;
public class EtatPersonnageKO extends EtatPersonnageAbstrait {
public EtatPersonnageKO(Personnage perso) {
super(perso);
// TODO Auto-generated constructor stub
}
}

View File

@ -1,5 +1,12 @@
package Etats;
import Person.Personnage;
public class EtatPersonnageOK extends EtatPersonnageAbstrait {
public EtatPersonnageOK(Personnage perso) {
super(perso);
// TODO Auto-generated constructor stub
}
}

View File

@ -11,13 +11,13 @@ public class FabriquePersonnagesBattleZone extends FabriquePersonnagesAbstraite
public ArrayList<Personnage> CreerPersonages(Organisation o) {
ArrayList<Personnage> list = new ArrayList<Personnage>();
PersonnageBattleZone p1 = new PersonnageBattleZone(null, "P1");
PersonnageBattleZone p1 = new PersonnageBattleZone("Bob",100.0,1.0,1.0);
list.add(p1);
PersonnageBattleZone p2 = new PersonnageBattleZone(null, "P2");
PersonnageBattleZone p2 = new PersonnageBattleZone("Jo",100.0,1.0,1.0);
list.add(p2);
PersonnageBattleZone p3 = new PersonnageBattleZone(null, "P3");
PersonnageBattleZone p3 = new PersonnageBattleZone("Max",100.0,1.0,1.0);
list.add(p3);
PersonnageBattleZone p4 = new PersonnageBattleZone(null, "P4");
PersonnageBattleZone p4 = new PersonnageBattleZone("Zac",100.0,1.0,1.0);
list.add(p4);
return list;
}

View File

@ -1,13 +1,19 @@
package Objets;
import Cases.CaseAbstraite;
import Person.Personnage;
public abstract class ObjetAbstrait {
CaseAbstraite caseAbstraite;
public abstract class ObjetAbstrait extends Personnage {
Personnage perso;
CaseAbstraite positionCourante;
String nom;
public ObjetAbstrait(String nom, CaseAbstraite c) {
this.caseAbstraite = c;
this.nom = nom;
}
protected ObjetAbstrait(String name, double lifePoint, double strength,
double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
}
}

View File

@ -0,0 +1,13 @@
package Objets;
public class ObjetAvecBonusForce extends ObjetAbstrait {
protected ObjetAvecBonusForce(String name, double lifePoint,
double strength, double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
}
public double getPointsDeVie() {return perso.getPointsDeVie() + 20;}
public double getForce() {return perso.getForce() + 0.5;}
}

View File

@ -0,0 +1,12 @@
package Objets;
public class ObjetAvecBonusPV extends ObjetAbstrait {
protected ObjetAvecBonusPV(String name, double lifePoint, double strength,
double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
}
public double getPointsDeVie() {return perso.getPointsDeVie() + 80;}
}

View File

@ -0,0 +1,12 @@
package Objets;
public class ObjetAvecBonusVitesse extends ObjetAbstrait {
protected ObjetAvecBonusVitesse(String name, double lifePoint,
double strength, double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
}
public double getPointsDeVie() {return perso.getVitesse() + 2;}
}

View File

@ -0,0 +1,15 @@
package Objets;
import Person.PersonnageBattleZone;
public class PersonnageBattleZoneAvecUnHoverboard extends ObjetAvecBonusVitesse {
protected PersonnageBattleZoneAvecUnHoverboard(String name,
double lifePoint, double strength, double speed, PersonnageBattleZone PBZ) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
this.perso=PBZ;
}
}

View File

@ -0,0 +1,15 @@
package Objets;
import Person.PersonnageBattleZone;
public class PersonnageBattleZoneAvecUnMarteau extends ObjetAvecBonusForce {
protected PersonnageBattleZoneAvecUnMarteau(String name, double lifePoint,
double strength, double speed, PersonnageBattleZone PBZ) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
this.perso=PBZ;
}
}

View File

@ -0,0 +1,15 @@
package Objets;
import Person.PersonnageBattleZone;
public class PersonnageBattleZoneAvecUneArmure extends ObjetAvecBonusPV {
protected PersonnageBattleZoneAvecUneArmure(String name, double lifePoint,
double strength, double speed, PersonnageBattleZone PBZ) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
this.perso=PBZ;
}
}

View File

@ -1,56 +1,101 @@
package Person;
import Cases.CaseAbstraite;
import Comportements.ComportementEmmetreSon;
import Composition.PersonnagesAbstraits;
import Observateur.ObservateurAbstrait;
import Observateur.Organisation;
import Observateur.eMode;
import Etats.EEtat;
import Etats.EtatPersonnageAbstrait;
import Etats.EtatPersonnageKO;
import Etats.EtatPersonnageOK;
public class Personnage extends PersonnagesAbstraits implements ObservateurAbstrait {
protected CaseAbstraite caseCourante;
public class Personnage extends PersonnagesAbstraits {
protected CaseAbstraite caseCourante;
private EtatPersonnageAbstrait etatCourant;
protected String nom;
//protected ComportementEmmetreSon comportementEmmetreSon;
//protected eMode etatFonctionnement = eMode.ND;
protected Personnage(Organisation etatMajor, String nom) {
this.nom = nom;
//this.comportementEmmetreSon = null;
if (etatMajor != null)
etatMajor.attach(this);
protected String groupe;
protected double pointsDeVie;
protected double force;
protected double vitesse;
protected Personnage(String name, double lifePoint, double strength, double speed) {
this.nom = name;
this.pointsDeVie=lifePoint;
this.force=strength;
this.vitesse=speed;
this.caseCourante=null;
this.etatCourant= new EtatPersonnageOK(this);
}
public void ChangeEtat(EEtat NouvelEtat)
{
switch(NouvelEtat)
{
case EtatOK:
etatCourant = new EtatPersonnageOK(this);
break;
case EtatKO:
etatCourant = new EtatPersonnageKO(this);
break;
default:
break;
}
}
public EtatPersonnageAbstrait getEtatCourant() {
return etatCourant;
}
public void setEtatCourant(EtatPersonnageAbstrait etatCourant) {
this.etatCourant = etatCourant;
}
public double getPointsDeVie() {
return pointsDeVie;
}
public void setPointsDeVie(double pointsDeVie) {
this.pointsDeVie = pointsDeVie;
}
public double getForce() {
return force;
}
public void setForce(double force) {
this.force = force;
}
public double getVitesse() {
return vitesse;
}
public void setVitesse(double vitesse) {
this.vitesse = vitesse;
}
public String getGroupe() {
return groupe;
}
public void setGroupe(String equipe) {
groupe = equipe;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getNom() {
return nom;
}
/* public void setComportementEmmetreSon(ComportementEmmetreSon comportementEmmetreSon) {
this.comportementEmmetreSon = comportementEmmetreSon;
}
public String EmmetreSon() {
return this.comportementEmmetreSon.emmetreSon();
}
public void update(eMode comportement) {
this.etatFonctionnement = comportement;
}
public String getEtat() {
String etat;
switch (etatFonctionnement) {
case GUERRE:
etat = "En Guerre !";
break;
case PAIX:
etat = "En paix !";
break;
default:
etat = "De quoi ?";
break;
}
return etat;
}*/
public CaseAbstraite getCaseCourante() {
return caseCourante;
}

View File

@ -4,8 +4,8 @@ import Observateur.Organisation;
public class PersonnageBattleGoal extends Personnage {
protected PersonnageBattleGoal(Organisation etatMajor, String nom) {
super(etatMajor, nom);
protected PersonnageBattleGoal(String name, double lifePoint, double strength, double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
}

View File

@ -4,8 +4,8 @@ import Observateur.Organisation;
public class PersonnageBattleSnow extends Personnage{
protected PersonnageBattleSnow(Organisation etatMajor, String nom) {
super(etatMajor, nom);
protected PersonnageBattleSnow(String name, double lifePoint, double strength, double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
}

View File

@ -8,8 +8,10 @@ import java.util.Random;
public class PersonnageBattleZone extends Personnage {
Color couleur;
public PersonnageBattleZone(Organisation etatMajor, String nom) {
super(etatMajor, nom);
public PersonnageBattleZone(String name, double lifePoint, double strength, double speed) {
super(name, lifePoint, strength, speed);
// TODO Auto-generated constructor stub
// Couleur Aléatoire
Random rand = new Random();