diff --git a/src/tpqu02/WarriorCard.java b/src/tpqu02/WarriorCard.java new file mode 100644 index 0000000000000000000000000000000000000000..dbcd7185251f1ed4fa24335a59a4f426764b848f --- /dev/null +++ b/src/tpqu02/WarriorCard.java @@ -0,0 +1,56 @@ +package tpqu02; +public class WarriorCard { + private String name; + private int strength; + private int agility; + + //** + /* <b>Cartes de combats</b> + */ + public WarriorCard(String name,int strength,int agility){ + this.name = name; + this.strength = strength; + this.agility = agility; + } + + //** + /* Vérifie l'égalité + */ + public boolean equals(Object objet){ + if(this==objet)return true; + if(objet==null)return false; + + if(this.getClass()!=objet.getClass()){return false;} + //downcast pour adapter l'equals à Warrior Card + WarriorCard other=(WarriorCard) objet; + + if(this.name==null){ + if(other.name != null) return false; + }else if(!this.name.equals(other.name)) return false; + return true; + } //equals de string; pas de de lui-même + + //** + /* Compare la <b>force</b> de deux guerriers + */ + public int compareStrength(WarriorCard other){ + return this.strength-other.strength; + } + //** + /* Compare l'<b>agilité</b> de deux guerriers + */ + public int compareAgility(WarriorCard other){ + return this.agility-other.agility; + } + //** + /* Renvoie les <b>stats</b> et le nom du guerrier + */ + public String toString(){ + return this.name+"[S="+this.strength+",A="+agility+"]."; + } + + + + //5 error 8 warning, je pète ma bière, ma lubullule +} + \ No newline at end of file