Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TP monstre
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alan BILLY
TP monstre
Commits
a91e296b
Commit
a91e296b
authored
Dec 05, 2023
by
Alan BILLY
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout de la fonction clone()
parent
f3ad305e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
Main.java
Monstrre/src/Main.java
+9
-1
MonstreBuilder.java
Monstrre/src/MonstreBuilder.java
+1
-0
MonstreUniverselBuilder.java
Monstrre/src/MonstreUniverselBuilder.java
+6
-0
No files found.
Monstrre/src/Main.java
View file @
a91e296b
...
...
@@ -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
());
...
...
Monstrre/src/MonstreBuilder.java
View file @
a91e296b
...
...
@@ -13,4 +13,5 @@ public interface MonstreBuilder {
public
void
buildSante
(
int
sante
);
public
void
buildPuissance
(
int
puissance
);
Monstre
build
();
public
Monstre
clone
(
Monstre
monstre
);
}
Monstrre/src/MonstreUniverselBuilder.java
View file @
a91e296b
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment