Commit a91e296b authored by Alan BILLY's avatar Alan BILLY

Ajout de la fonction clone()

parent f3ad305e
...@@ -5,7 +5,7 @@ public class Main { ...@@ -5,7 +5,7 @@ public class Main {
public static void main(String[] args) { public static void main(String[] args) {
MonstreBuilder builder = new MonstreUniverselBuilder(); MonstreBuilder builder = new MonstreUniverselBuilder();
MonstreDirector director = new MonstreDirector(builder); MonstreDirector director = new MonstreDirector(builder);
Monstre m1; Monstre m1 = null;
try { try {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
...@@ -41,6 +41,14 @@ public class Main { ...@@ -41,6 +41,14 @@ public class Main {
System.out.println("Choix invalide."); System.out.println("Choix invalide.");
break; 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(); scanner.close();
} catch (Exception e) { } catch (Exception e) {
System.out.println("An error occurred: " + e.getMessage()); System.out.println("An error occurred: " + e.getMessage());
......
...@@ -13,4 +13,5 @@ public interface MonstreBuilder { ...@@ -13,4 +13,5 @@ public interface MonstreBuilder {
public void buildSante(int sante); public void buildSante(int sante);
public void buildPuissance(int puissance); public void buildPuissance(int puissance);
Monstre build(); Monstre build();
public Monstre clone(Monstre monstre);
} }
...@@ -66,4 +66,10 @@ public class MonstreUniverselBuilder implements MonstreBuilder { ...@@ -66,4 +66,10 @@ public class MonstreUniverselBuilder implements MonstreBuilder {
return monstre; 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