Battleship Pseudocode Project
Class Battleship
main()
//Declarations
string GUESS = [x,y]
num SHIPGRIDS= [10][10]
num GUESSGRIDS = [10][10]
string COLUMN = [0,1,2,3,4,5,6,7,8,9,10]
string ROW = [A,B,C,D,E,F,G,H,I,J]
num int WATER = 0
num int HIT = 1
num int CARRIER = 5
num int BATTLESHIP = 4
num int DESTROYER = 3
num int SUBMARINE = 3
num int PATROL_BOAT = 2
num HITCOUNT = 0
string TOTAL_SHIPS = 5
string name PLAYER 1
string name PLAYER 2
output PLAYER 1, [ROW][COLUMN]SHIPGRIDS, [ROW][COLUMN]GUESSGRIDS
output PLAYER 2, [ROW][COLUMN]SHIPGRIDS, [ROW][COLUMN]GUESSGRIDS
output “Players place your ships!”
input PLAYER 1 readKey()
input PLAYER 2 readKey()
output “Pick a player to go first; PLAYER 1 or PLAYER 2”
input readKey()
get GUESS
if [x,y] = HIT
then TOTAL_SHIPS =< 5
Output “Hit! Nice job. Next Players turn!”
or [x,y] = WATER
and TOTAL_SHIPS =< 5
output “Miss, Next player turn!”
elseif TOTAL_SHIPS <1
output “ Game over, Player wins”
endif
endif
endGet
main()
//Declarations
string GUESS = [x,y]
num SHIPGRIDS= [10][10]
num GUESSGRIDS = [10][10]
string COLUMN = [0,1,2,3,4,5,6,7,8,9,10]
string ROW = [A,B,C,D,E,F,G,H,I,J]
num int WATER = 0
num int HIT = 1
num int CARRIER = 5
num int BATTLESHIP = 4
num int DESTROYER = 3
num int SUBMARINE = 3
num int PATROL_BOAT = 2
num HITCOUNT = 0
string TOTAL_SHIPS = 5
string name PLAYER 1
string name PLAYER 2
output PLAYER 1, [ROW][COLUMN]SHIPGRIDS, [ROW][COLUMN]GUESSGRIDS
output PLAYER 2, [ROW][COLUMN]SHIPGRIDS, [ROW][COLUMN]GUESSGRIDS
output “Players place your ships!”
input PLAYER 1 readKey()
input PLAYER 2 readKey()
output “Pick a player to go first; PLAYER 1 or PLAYER 2”
input readKey()
get GUESS
if [x,y] = HIT
then TOTAL_SHIPS =< 5
Output “Hit! Nice job. Next Players turn!”
or [x,y] = WATER
and TOTAL_SHIPS =< 5
output “Miss, Next player turn!”
elseif TOTAL_SHIPS <1
output “ Game over, Player wins”
endif
endif
endGet