Package battleship.model
Class Game
java.lang.Object
battleship.model.Game
public class Game
extends java.lang.Object
Main game class
-
Field Summary
Fields Modifier and Type Field Description Player
currentPlayer
Player[]
players
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
changeCurrentPlayer()
void
checkDrownedShips()
Update ship to know if they're drownedPlayer
getCurrentPlayer()
Player
getOtherPlayer()
Player
getOtherPlayer(Player player)
Player
getWinner()
void
move(Pair<java.lang.Integer,java.lang.Integer> move)
Play the selected move from current player in gridvoid
Play(View view)
game loopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
players
-
currentPlayer
-
-
Constructor Details
-
Game
-
-
Method Details
-
getCurrentPlayer
-
getOtherPlayer
-
getOtherPlayer
-
changeCurrentPlayer
public void changeCurrentPlayer() -
checkDrownedShips
public void checkDrownedShips()Update ship to know if they're drowned -
getWinner
- Returns:
- player 1 if player 2' ships are drowned, or player 2 if player1' ships are drowned, null otherwise
-
move
Play the selected move from current player in grid- Parameters:
move
- selected player move
-
Play
game loop
-