Commit deeec8bc authored by Aroubate Hamza's avatar Aroubate Hamza
Browse files

moitié TP2

parent 3e3572d7
......@@ -119,5 +119,17 @@ public class ClassMain {
System.out.println("Piece : " + pc.toString());
System.out.println("############");
System.out.println("Test Retirer Piece");
Objet objetRetourne = pc.retirer(o);
System.out.println("identiques ?" + objetRetourne.equals(o));
System.out.println("Piece : " + pc.toString());
objetRetourne = pc.retirer(pb.getNom());
System.out.println("identiques ?" + objetRetourne.equals(pb));
System.out.println("Piece : " + pc.toString());
System.out.println("############");
}
}
package fr.insarouen.asi.prog.asiaventure.elements.vivants;
import fr.insarouen.asi.prog.asiaventure.Monde;
import fr.insarouen.asi.prog.asiaventure.elements.Entite;
import fr.insarouen.asi.prog.asiaventure.elements.objets.Objet;
import fr.insarouen.asi.prog.asiaventure.elements.structure.Piece;
public abstract class Vivant extends Entite {
private int pointVie;
private int pointForce;
private Piece piece;
private Objet[] objets = new Objet[0];
public Vivant(String nom, Monde monde, int pointVie, int pointForce, Piece piece, Objet... objets){
}
}
......@@ -37,6 +37,21 @@ public class Piece extends ElementStructurel{
return result;
}
public boolean contientObjet(Objet obj) {
return contientObjet(obj.getNom());
}
public boolean contientObjet(String nom) {
for (int i = 0; i<this.tableauObjet.length; i++)
if (this.tableauObjet[i].getNom().equals(nom))
return true;
return false;
}
public Objet[] getObjets() {
return this.tableauObjet;
}
public String toString(){
String res = "Nom Piece :" +this.getNom()+ ";\n";
res += "Nom Monde :";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment