objet et decorateur
This commit is contained in:
parent
a795db4f6e
commit
2e1eafcc77
5
src/Etats/EEtat.java
Normal file
5
src/Etats/EEtat.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package Etats;
|
||||||
|
|
||||||
|
public enum EEtat {
|
||||||
|
EtatOK,EtatKO
|
||||||
|
}
|
@ -1,5 +1,12 @@
|
|||||||
package Etats;
|
package Etats;
|
||||||
|
|
||||||
|
import Person.Personnage;
|
||||||
|
|
||||||
public abstract class EtatPersonnageAbstrait {
|
public abstract class EtatPersonnageAbstrait {
|
||||||
|
|
||||||
|
protected Personnage joueur;
|
||||||
|
|
||||||
|
protected EtatPersonnageAbstrait(Personnage perso){
|
||||||
|
this.joueur = perso;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package Etats;
|
package Etats;
|
||||||
|
|
||||||
|
import Person.Personnage;
|
||||||
|
|
||||||
public class EtatPersonnageKO extends EtatPersonnageAbstrait {
|
public class EtatPersonnageKO extends EtatPersonnageAbstrait {
|
||||||
|
|
||||||
|
public EtatPersonnageKO(Personnage perso) {
|
||||||
|
super(perso);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package Etats;
|
package Etats;
|
||||||
|
|
||||||
|
import Person.Personnage;
|
||||||
|
|
||||||
public class EtatPersonnageOK extends EtatPersonnageAbstrait {
|
public class EtatPersonnageOK extends EtatPersonnageAbstrait {
|
||||||
|
|
||||||
|
public EtatPersonnageOK(Personnage perso) {
|
||||||
|
super(perso);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@ public class FabriquePersonnagesBattleZone extends FabriquePersonnagesAbstraite
|
|||||||
public ArrayList<Personnage> CreerPersonages(Organisation o) {
|
public ArrayList<Personnage> CreerPersonages(Organisation o) {
|
||||||
ArrayList<Personnage> list = new ArrayList<Personnage>();
|
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);
|
list.add(p1);
|
||||||
PersonnageBattleZone p2 = new PersonnageBattleZone(null, "P2");
|
PersonnageBattleZone p2 = new PersonnageBattleZone("Jo",100.0,1.0,1.0);
|
||||||
list.add(p2);
|
list.add(p2);
|
||||||
PersonnageBattleZone p3 = new PersonnageBattleZone(null, "P3");
|
PersonnageBattleZone p3 = new PersonnageBattleZone("Max",100.0,1.0,1.0);
|
||||||
list.add(p3);
|
list.add(p3);
|
||||||
PersonnageBattleZone p4 = new PersonnageBattleZone(null, "P4");
|
PersonnageBattleZone p4 = new PersonnageBattleZone("Zac",100.0,1.0,1.0);
|
||||||
list.add(p4);
|
list.add(p4);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
package Objets;
|
package Objets;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Cases.CaseAbstraite;
|
||||||
|
import Person.Personnage;
|
||||||
|
|
||||||
public abstract class ObjetAbstrait {
|
public abstract class ObjetAbstrait extends Personnage {
|
||||||
CaseAbstraite caseAbstraite;
|
|
||||||
|
Personnage perso;
|
||||||
|
CaseAbstraite positionCourante;
|
||||||
String nom;
|
String nom;
|
||||||
|
|
||||||
public ObjetAbstrait(String nom, CaseAbstraite c) {
|
protected ObjetAbstrait(String name, double lifePoint, double strength,
|
||||||
this.caseAbstraite = c;
|
double speed) {
|
||||||
this.nom = nom;
|
super(name, lifePoint, strength, speed);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
13
src/Objets/ObjetAvecBonusForce.java
Normal file
13
src/Objets/ObjetAvecBonusForce.java
Normal 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;}
|
||||||
|
}
|
12
src/Objets/ObjetAvecBonusPV.java
Normal file
12
src/Objets/ObjetAvecBonusPV.java
Normal 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;}
|
||||||
|
}
|
12
src/Objets/ObjetAvecBonusVitesse.java
Normal file
12
src/Objets/ObjetAvecBonusVitesse.java
Normal 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;}
|
||||||
|
}
|
15
src/Objets/PersonnageBattleZoneAvecUnHoverboard.java
Normal file
15
src/Objets/PersonnageBattleZoneAvecUnHoverboard.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/Objets/PersonnageBattleZoneAvecUnMarteau.java
Normal file
15
src/Objets/PersonnageBattleZoneAvecUnMarteau.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/Objets/PersonnageBattleZoneAvecUneArmure.java
Normal file
15
src/Objets/PersonnageBattleZoneAvecUneArmure.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,56 +1,101 @@
|
|||||||
package Person;
|
package Person;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Cases.CaseAbstraite;
|
||||||
import Comportements.ComportementEmmetreSon;
|
|
||||||
import Composition.PersonnagesAbstraits;
|
import Composition.PersonnagesAbstraits;
|
||||||
import Observateur.ObservateurAbstrait;
|
import Etats.EEtat;
|
||||||
import Observateur.Organisation;
|
import Etats.EtatPersonnageAbstrait;
|
||||||
import Observateur.eMode;
|
import Etats.EtatPersonnageKO;
|
||||||
|
import Etats.EtatPersonnageOK;
|
||||||
|
|
||||||
public class Personnage extends PersonnagesAbstraits implements ObservateurAbstrait {
|
public class Personnage extends PersonnagesAbstraits {
|
||||||
protected CaseAbstraite caseCourante;
|
protected CaseAbstraite caseCourante;
|
||||||
|
private EtatPersonnageAbstrait etatCourant;
|
||||||
protected String nom;
|
protected String nom;
|
||||||
//protected ComportementEmmetreSon comportementEmmetreSon;
|
protected String groupe;
|
||||||
//protected eMode etatFonctionnement = eMode.ND;
|
protected double pointsDeVie;
|
||||||
|
protected double force;
|
||||||
|
protected double vitesse;
|
||||||
|
|
||||||
protected Personnage(Organisation etatMajor, String nom) {
|
protected Personnage(String name, double lifePoint, double strength, double speed) {
|
||||||
this.nom = nom;
|
this.nom = name;
|
||||||
//this.comportementEmmetreSon = null;
|
this.pointsDeVie=lifePoint;
|
||||||
|
this.force=strength;
|
||||||
|
this.vitesse=speed;
|
||||||
|
|
||||||
if (etatMajor != null)
|
this.caseCourante=null;
|
||||||
etatMajor.attach(this);
|
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() {
|
public String getNom() {
|
||||||
return nom;
|
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() {
|
public CaseAbstraite getCaseCourante() {
|
||||||
return caseCourante;
|
return caseCourante;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import Observateur.Organisation;
|
|||||||
|
|
||||||
public class PersonnageBattleGoal extends Personnage {
|
public class PersonnageBattleGoal extends Personnage {
|
||||||
|
|
||||||
protected PersonnageBattleGoal(Organisation etatMajor, String nom) {
|
protected PersonnageBattleGoal(String name, double lifePoint, double strength, double speed) {
|
||||||
super(etatMajor, nom);
|
super(name, lifePoint, strength, speed);
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import Observateur.Organisation;
|
|||||||
|
|
||||||
public class PersonnageBattleSnow extends Personnage{
|
public class PersonnageBattleSnow extends Personnage{
|
||||||
|
|
||||||
protected PersonnageBattleSnow(Organisation etatMajor, String nom) {
|
protected PersonnageBattleSnow(String name, double lifePoint, double strength, double speed) {
|
||||||
super(etatMajor, nom);
|
super(name, lifePoint, strength, speed);
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,10 @@ import java.util.Random;
|
|||||||
public class PersonnageBattleZone extends Personnage {
|
public class PersonnageBattleZone extends Personnage {
|
||||||
Color couleur;
|
Color couleur;
|
||||||
|
|
||||||
public PersonnageBattleZone(Organisation etatMajor, String nom) {
|
public PersonnageBattleZone(String name, double lifePoint, double strength, double speed) {
|
||||||
super(etatMajor, nom);
|
super(name, lifePoint, strength, speed);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
|
||||||
|
|
||||||
// Couleur Aléatoire
|
// Couleur Aléatoire
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
Loading…
Reference in New Issue
Block a user