Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jamal ATTOU
projetS2-2021-3-SF
Commits
9a2754aa
Commit
9a2754aa
authored
Jun 25, 2021
by
Jocelyn MASSEROT
Browse files
Jocelyn Julien - MenuCreationFlotte : traitement de la dernière erreur
parent
96caa1fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/controleurs/ListenerJouer.java
View file @
9a2754aa
...
...
@@ -45,6 +45,11 @@ public class ListenerJouer implements ActionListener {
dialog
.
setAlwaysOnTop
(
true
);
dialog
.
setVisible
(
true
);
}
}
else
{
JOptionPane
optionPane
=
new
JOptionPane
(
"Votre flotte n'est pas complète !\nVeuillez placer le bateau supprimé"
,
JOptionPane
.
ERROR_MESSAGE
);
JDialog
dialog
=
optionPane
.
createDialog
(
"ERREUR"
);
dialog
.
setAlwaysOnTop
(
true
);
dialog
.
setVisible
(
true
);
}
}
}
\ No newline at end of file
src/vues/MenuCreationFlotte.java
View file @
9a2754aa
...
...
@@ -423,7 +423,7 @@ public class MenuCreationFlotte extends JFrame {
case
2
:
if
(!
trouverbateau
(
textfront
.
getText
())
&&
!
trouverbateau
(
textpoupe
.
getText
())){
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
1
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
1
))
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
1
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
1
)
&&
(
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
0
))
)
{
try
{
Destroyer
ds
=
new
Destroyer
(
"un torpilleur"
,
textfront
.
getText
(),
textpoupe
.
getText
());
...
...
@@ -439,9 +439,8 @@ public class MenuCreationFlotte extends JFrame {
}
catch
(
CoordsBadShipException
e
)
{
e
.
printStackTrace
();
}
}
else
{
System
.
out
.
println
(
"les deux morceaux ne se suivent pas"
);
}
else
{
result
(
2
);
}
}
else
{
...
...
@@ -452,7 +451,7 @@ public class MenuCreationFlotte extends JFrame {
case
3
:
if
(!
trouverbateau
(
textfront
.
getText
())
&&
!
trouverbateau
(
textpoupe
.
getText
())){
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
2
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
2
))
{
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
2
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
2
)
&&
(
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
0
))
)
{
try
{
Cruiser
cs
=
new
Cruiser
(
"un croiseur"
,
textfront
.
getText
(),
textpoupe
.
getText
());
...
...
@@ -468,6 +467,8 @@ public class MenuCreationFlotte extends JFrame {
}
catch
(
CoordsBadShipException
e
)
{
e
.
printStackTrace
();
}
}
else
{
result
(
2
);
}
}
else
{
result
(
1
);
...
...
@@ -477,7 +478,7 @@ public class MenuCreationFlotte extends JFrame {
case
4
:
if
(!
trouverbateau
(
textfront
.
getText
())
&&
!
trouverbateau
(
textpoupe
.
getText
())){
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
3
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
3
))
{
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
3
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
3
)
&&
(
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
0
))
)
{
try
{
Battleship
bs
=
new
Battleship
(
"un cuirassé"
,
textfront
.
getText
(),
textpoupe
.
getText
());
...
...
@@ -494,6 +495,9 @@ public class MenuCreationFlotte extends JFrame {
e
.
printStackTrace
();
}
}
else
{
result
(
2
);
}
}
else
{
result
(
1
);
}
...
...
@@ -501,7 +505,7 @@ public class MenuCreationFlotte extends JFrame {
case
5
:
if
(!
trouverbateau
(
textfront
.
getText
())
&&
!
trouverbateau
(
textpoupe
.
getText
())){
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
4
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
4
))
{
if
(((
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
4
)
&&
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
0
))
||
(
(
abs
(
listcoord
.
get
(
0
).
getY
()-
listcoord
.
get
(
1
).
getY
())==
4
)
&&
(
abs
(
listcoord
.
get
(
0
).
getX
()-
listcoord
.
get
(
1
).
getX
())==
0
))
)
{
try
{
AircraftCarrier
ac
=
new
AircraftCarrier
(
"un Porte-Avion"
,
textfront
.
getText
(),
textpoupe
.
getText
());
...
...
@@ -517,6 +521,8 @@ public class MenuCreationFlotte extends JFrame {
}
catch
(
CoordsBadShipException
e
)
{
e
.
printStackTrace
();
}
}
else
{
result
(
2
);
}
}
else
{
result
(
1
);
...
...
@@ -610,7 +616,7 @@ public class MenuCreationFlotte extends JFrame {
Si etat :
=1 : Il y a déjà un bateau sur l'un des extrémités
=2 : La taille indiquée n'est pas respectée
=3 : Il y a un
caractère spécial
dans les coordonnées indidées (renvoie aussi que la taille n'est pas respectée)
=3 : Il y a un
non compris entre A et J ou 1 et 10
dans les coordonnées indidées (renvoie aussi que la taille n'est pas respectée)
*/
public
void
result
(
int
etat
){
...
...
@@ -628,7 +634,7 @@ public class MenuCreationFlotte extends JFrame {
dialog2
.
setVisible
(
true
);
break
;
case
3
:
JOptionPane
optionPane3
=
new
JOptionPane
(
"Il y a un caractère
spécial dans les coordonnées indidées
!"
,
JOptionPane
.
ERROR_MESSAGE
);
JOptionPane
optionPane3
=
new
JOptionPane
(
"Il y a un caractère
de vos coordonnées non indiqué dans la table
!"
,
JOptionPane
.
ERROR_MESSAGE
);
JDialog
dialog3
=
optionPane3
.
createDialog
(
"Placement du bateau"
);
dialog3
.
setAlwaysOnTop
(
true
);
dialog3
.
setVisible
(
true
);
...
...
Write
Preview
Supports
Markdown
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