Commit a91e296b authored by Alan BILLY's avatar Alan BILLY

Ajout de la fonction clone()

parent f3ad305e
......@@ -5,7 +5,7 @@ public class Main {
public static void main(String[] args) {
MonstreBuilder builder = new MonstreUniverselBuilder();
MonstreDirector director = new MonstreDirector(builder);
Monstre m1;
Monstre m1 = null;
try {
Scanner scanner = new Scanner(System.in);
......@@ -41,6 +41,14 @@ public class Main {
System.out.println("Choix invalide.");
break;
}
System.out.println("Le monstre va attaquer !");
Thread.sleep(2000);
System.out.println("Pour vous protéger vous allez cloner votre monstre puis attaquer avec vos monstres !");
Thread.sleep(2000);
Monstre m2 = builder.clone(m1);
System.out.println(m2);
scanner.close();
} catch (Exception e) {
System.out.println("An error occurred: " + e.getMessage());
......
......@@ -13,4 +13,5 @@ public interface MonstreBuilder {
public void buildSante(int sante);
public void buildPuissance(int puissance);
Monstre build();
public Monstre clone(Monstre monstre);
}
......@@ -66,4 +66,10 @@ public class MonstreUniverselBuilder implements MonstreBuilder {
return monstre;
}
@Override
public Monstre clone(Monstre monstre) {
this.monstre = monstre;
return this.monstre;
}
}
\ No newline at end of file
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