Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Daniele Lucas
ItiAdventure
Commits
f6f494de
Commit
f6f494de
authored
Feb 08, 2021
by
LucasDANIELE
Browse files
Fin du TP1
parent
d1eebd0d
Changes
15
Hide whitespace changes
Inline
Side-by-side
ITIAdventure/classes/ClassMain.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/classes/fr/insarouen/asi/prog/asiaventure/EtatDuJeu.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/classes/fr/insarouen/asi/prog/asiaventure/Monde.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/classes/fr/insarouen/asi/prog/asiaventure/elements/Entite.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/classes/fr/insarouen/asi/prog/asiaventure/elements/Etat.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/classes/fr/insarouen/asi/prog/asiaventure/elements/objets/Objet.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/classes/fr/insarouen/asi/prog/asiaventure/elements/objets/PiedDeBiche.class
0 → 100644
View file @
f6f494de
File added
ITIAdventure/src/ClassMain.java
View file @
f6f494de
package
fr.insarouen.asi.prog.asiaventure
;
import
fr.insarouen.asi.prog.asiaventure.*
;
import
fr.insarouen.asi.prog.asiaventure.elements.*
;
import
fr.insarouen.asi.prog.asiaventure.elements.objets.*
;
public
class
c
lassMain
{
public
class
C
lassMain
{
public
static
void
main
(
String
[]
args
){
Monde
monde
=
new
Monde
(
"Terre"
);
Entite
entite
=
new
Entite
(
"SUPER_NOM"
,
monde
);
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"##TestMain##"
);
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test creation monde"
);
Monde
monde
=
new
Monde
(
"nouveauMonde"
);
System
.
out
.
println
(
monde
.
toString
());
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test creation et ajout de 2 entites"
);
Entite
entite1
=
new
Entite
(
"nom1"
,
monde
);
Entite
entite2
=
new
Entite
(
"nom2"
,
monde
);
System
.
out
.
println
(
entite1
.
toString
());
System
.
out
.
println
(
entite2
.
toString
());
System
.
out
.
println
(
monde
.
toString
());
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test entite equals & hashcode"
);
System
.
out
.
println
(
"entite1 = entite1 ? "
+
entite1
.
equals
(
entite1
));
System
.
out
.
println
(
"entite1 = entite2 ? "
+
entite1
.
equals
(
entite2
));
System
.
out
.
println
(
"hashcode entite1: "
+
entite1
.
hashCode
());
System
.
out
.
println
(
"hashcode entite2: "
+
entite2
.
hashCode
());
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test Monde.getEntite"
);
Entite
entite3
=
monde
.
getEntite
(
"nom1"
);
System
.
out
.
println
(
entite3
.
toString
());
System
.
out
.
println
(
"Entite trouve == entite1 ? "
+
entite3
.
equals
(
entite1
));
System
.
out
.
println
(
"hashcode entite1: "
+
entite1
.
hashCode
());
System
.
out
.
println
(
"hashcode trouve: "
+
entite3
.
hashCode
());
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test Valeurs Etat"
);
for
(
Etat
c
:
Etat
.
values
()){
//cf javadoc
System
.
out
.
println
(
c
);
}
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test Valeurs EtatDuJeu"
);
for
(
EtatDuJeu
c
:
EtatDuJeu
.
values
()){
//cf javadoc
System
.
out
.
println
(
c
);
}
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test Objet"
);
Objet
objet
=
new
Objet
(
"objet 1"
,
monde
);
System
.
out
.
println
(
"deplacable ? "
+
objet
.
estDeplacable
());
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test Pied De Biche"
);
PiedDeBiche
pdb
=
new
PiedDeBiche
(
"Super Pied de Biche"
,
monde
);
System
.
out
.
println
(
"deplacable ? "
+
pdb
.
estDeplacable
());
System
.
out
.
println
(
"############"
);
System
.
out
.
println
(
"Test Element Structurel"
);
PiedDeBiche
es
=
new
PiedDeBiche
(
"Element Structurel"
,
monde
);
System
.
out
.
println
(
"deplacable ? "
+
es
.
estDeplacable
());
System
.
out
.
println
(
monde
.
getNom
()
);
System
.
out
.
println
(
"############"
);
}
}
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/EtatDuJeu.java
0 → 100644
View file @
f6f494de
package
fr.insarouen.asi.prog.asiaventure
;
public
enum
EtatDuJeu
{
ECHEC
,
ENCOURS
,
SUCCES
;
}
\ No newline at end of file
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/Monde.java
View file @
f6f494de
...
...
@@ -4,7 +4,7 @@ import fr.insarouen.asi.prog.asiaventure.elements.*;
public
class
Monde
{
private
String
nom
;
private
Entite
[]
entite
;
private
Entite
[]
tableauEntites
=
new
Entite
[
0
]
;
public
Monde
(
String
nom
){
this
.
nom
=
nom
;
...
...
@@ -13,15 +13,39 @@ public class Monde {
public
String
getNom
(){
return
this
.
nom
;
}
public
Entite
[]
getEntite
(){
return
this
.
entite
;
public
Entite
getEntite
(
String
nom
){
boolean
trouve
=
false
;
int
i
=
0
;
while
(!
trouve
&&
i
<
tableauEntites
.
length
){
if
(
tableauEntites
[
i
].
getNom
().
equals
(
nom
))
trouve
=
true
;
i
++;
}
if
(
trouve
)
return
tableauEntites
[
i
-
1
];
else
return
null
;
}
public
void
ajouter
(
Entite
nouvelleEntite
){
entite
[
entite
.
length
-
1
]
=
nouvelleEntite
;
Entite
tmp
[]
=
new
Entite
[
tableauEntites
.
length
+
1
];
for
(
int
i
=
0
;
i
<
tableauEntites
.
length
;
i
++)
{
tmp
[
i
]
=
tableauEntites
[
i
];
}
tmp
[
tmp
.
length
-
1
]
=
nouvelleEntite
;
tableauEntites
=
tmp
;
}
public
String
toString
(){
return
"Nom : "
+
this
.
nom
;
String
resultat
;
resultat
=
" Nom : "
+
this
.
getNom
()
+
";\n"
;
resultat
+=
" Entités : "
;
for
(
int
i
=
0
;
i
<
this
.
tableauEntites
.
length
;
i
++){
resultat
+=
" - "
+
tableauEntites
[
i
].
getNom
();
}
return
resultat
;
}
}
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/elements/Entite.java
View file @
f6f494de
...
...
@@ -10,9 +10,9 @@ public class Entite {
public
Entite
(
String
nom
,
Monde
monde
){
this
.
nom
=
nom
;
this
.
monde
=
monde
;
this
.
monde
.
ajouter
(
this
);
}
public
String
getNom
(){
return
this
.
nom
;
}
...
...
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/elements/Etat.java
0 → 100644
View file @
f6f494de
package
fr.insarouen.asi.prog.asiaventure.elements
;
public
enum
Etat
{
CASSE
,
DEVERROUILLE
,
FERME
,
OUVERT
,
VERROUILLE
;
}
\ No newline at end of file
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/elements/objets/Objet.java
0 → 100644
View file @
f6f494de
package
fr.insarouen.asi.prog.asiaventure.elements.objets
;
import
fr.insarouen.asi.prog.asiaventure.Monde
;
import
fr.insarouen.asi.prog.asiaventure.elements.Entite
;
public
class
Objet
extends
Entite
{
private
String
nom
;
private
Monde
monde
;
public
Objet
(
String
nom
,
Monde
monde
){
super
(
nom
,
monde
);
}
public
boolean
estDeplacable
(){
return
false
;
}
}
\ No newline at end of file
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/elements/objets/PiedDeBiche.java
0 → 100644
View file @
f6f494de
package
fr.insarouen.asi.prog.asiaventure.elements.objets
;
import
fr.insarouen.asi.prog.asiaventure.Monde
;
import
fr.insarouen.asi.prog.asiaventure.elements.objets.Objet
;
public
class
PiedDeBiche
extends
Objet
{
public
PiedDeBiche
(
String
nom
,
Monde
monde
){
super
(
nom
,
monde
);
}
public
boolean
estDeplacable
(){
return
true
;
}
}
ITIAdventure/src/fr/insarouen/asi/prog/asiaventure/elements/structure/ElementStructurel.java
0 → 100644
View file @
f6f494de
package
fr.insarouen.asi.prog.asiaventure.elements.structure
;
import
fr.insarouen.asi.prog.asiaventure.Monde
;
import
fr.insarouen.asi.prog.asiaventure.elements.Entite
;
public
class
ElementStructurel
extends
Entite
{
public
ElementStructurel
(
String
nom
,
Monde
monde
){
super
(
nom
,
monde
);
}
}
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