Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tristan MAISONNEUVE
projetS2-2021-23-LJ
Commits
0fbf3239
Commit
0fbf3239
authored
Jun 23, 2021
by
Tristan MAISONNEUVE
Browse files
Fennetre modif compo equip
parent
09604764
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/modele/info1/ships/CreationB.java
View file @
0fbf3239
...
...
@@ -50,7 +50,6 @@ public class CreationB {
switch
(
taille
)
{
case
1
:
if
(
pays
[
0
]!=
0
)
{
pays
[
0
]--;
try
{
Submarine
s
=
new
Submarine
(
"s"
,
co
[
0
]);
return
s
;
...
...
@@ -61,7 +60,6 @@ public class CreationB {
}
case
2
:
if
(
pays
[
1
]!=
0
)
{
pays
[
1
]--;
try
{
Destroyer
d
=
new
Destroyer
(
"d"
,
co
[
0
],
co
[
1
]);
return
d
;
...
...
@@ -72,7 +70,6 @@ public class CreationB {
}
case
3
:
if
(
pays
[
2
]!=
0
)
{
pays
[
2
]--;
try
{
Cruiser
c
=
new
Cruiser
(
"c"
,
co
[
0
],
co
[
1
]);
return
c
;
...
...
@@ -83,7 +80,6 @@ public class CreationB {
}
case
4
:
if
(
pays
[
3
]!=
0
)
{
pays
[
3
]--;
try
{
Battleship
b
=
new
Battleship
(
"b"
,
co
[
0
],
co
[
1
]);
return
b
;
...
...
@@ -94,7 +90,6 @@ public class CreationB {
}
case
5
:
if
(
pays
[
4
]!=
0
)
{
pays
[
4
]--;
try
{
AircraftCarrier
a
=
new
AircraftCarrier
(
"a"
,
co
[
0
],
co
[
1
]);
return
a
;
...
...
src/modele/info1/ships/Ship.java
View file @
0fbf3239
...
...
@@ -105,6 +105,10 @@ public abstract class Ship implements IShip {
return
-
1
;
}
public
ShipCategory
gettheCategory
(){
return
getCategory
();
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
...
...
src/vue/FenetreConnexion.java
View file @
0fbf3239
...
...
@@ -5,6 +5,7 @@ import info1.network.Player;
import
info1.ships.BadCoordException
;
import
info1.ships.CoordsBadShipException
;
import
info1.ships.ICoord
;
import
info1.ships.ShipCategory
;
import
modele.info1.ships.Bouttons
;
import
modele.info1.ships.Coord
;
import
modele.info1.ships.CreationB
;
...
...
@@ -14,6 +15,7 @@ import javax.swing.*;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.function.BiPredicate
;
...
...
@@ -100,6 +102,20 @@ public class FenetreConnexion extends JFrame {
final
CreationB
c
=
new
CreationB
(
co
[
0
],
co
[
1
],
pays
);
try
{
if
(
c
.
TestCreation
()!=
null
){
if
(
flotte
.
add
(
c
.
TestCreation
())==
0
){
c
.
TestCreation
().
gettheCategory
();
ShipCategory
s
=
c
.
TestCreation
().
gettheCategory
();
if
(
s
==
ShipCategory
.
SUBMARINE
){
pays
[
0
]--;
}
if
(
s
==
ShipCategory
.
DESTROYER
)
{
pays
[
1
]--;
}
if
(
s
==
ShipCategory
.
CRUISER
)
{
pays
[
2
]--;
}
if
(
s
==
ShipCategory
.
BATTLESHIP
)
{
pays
[
3
]--;
}
if
(
s
==
ShipCategory
.
AIRCRAFT_CARRIER
)
{
pays
[
4
]--;
}
System
.
out
.
println
(
Arrays
.
toString
(
pays
));
System
.
out
.
println
(
flotte
.
getShips
());
List
<
ICoord
>
listec
=
c
.
TestCreation
().
getCoords
();
for
(
int
i
=
0
;
i
<
100
;
i
++){
...
...
@@ -199,6 +215,7 @@ public class FenetreConnexion extends JFrame {
bouttons
[
i
].
getButton
().
setEnabled
(
true
);
}
flotte
=
new
NavyFleet
();
System
.
out
.
println
(
Arrays
.
toString
(
pays
));
}
});
...
...
@@ -214,6 +231,7 @@ public class FenetreConnexion extends JFrame {
bouttons
[
i
].
getButton
().
setEnabled
(
true
);
}
flotte
=
new
NavyFleet
();
System
.
out
.
println
(
Arrays
.
toString
(
pays
));
}
});
...
...
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