Skip to content
Snippets Groups Projects
Commit 5c6d103c authored by Malori Alvarez's avatar Malori Alvarez
Browse files

TPQU02

parent faee8fb4
No related branches found
No related tags found
No related merge requests found
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment