answersLogoWhite

0

first you have to initialize the array.

board : Array [1..10,1..10] of char;

then place the ships

board[2,2]:='A';

board[3,2]:='A';

board[4,2]:='A';

board[5,2]:='A';

board[6,2]:='A';

i would advise to use some simple coding for the ships such as

aircraft carrier code: A

so if aircraft carrier is at

[2,5] to [6,5], you can ask the user to enter two numbers (row, column) and check if

e.g. point [4,5] is assigned to 'A'

this is the coding i used for aircraft carrier, which is pretty much the same for all

while Gcount <> 17 do //5+4+3+3+2

begin

count:= count+1; // to count how many hits were required at the end

writeln('enter row you want to hit');

readln(row);

writeln('enter column you want to hit');

readln(col);

if board [row,col] = 'A' then

begin

Gcount:=Gcount+1;

writeln('you hit AirCraft Carrier');

end

else if board [row,col] = 'B' then

.... and so on....

i did not copy the exact code i used since there is a slight error. you can hit the same spot twice...

but in general to make such a game is not very hard

regards, Gohan (CY)

User Avatar

Wiki User

16y ago

What else can I help you with?