C
Make:1. Class of the vessel (the number of decks, the state of deck, the location of the deck, etc. In methods: designer, deconstructor, positioning of the ship on the field, damage, etc.)2. Shipping cycle3. A serious refacturing, since such a flogging is not good in one procedure. At least we don't read it. Just because I'm not the only one who's lying to read it. It's hard to write from scratch and accompany you, you'll be in one place to get the wrong variable, and you'll die. YES Algorithm. And Naturally.that you can't find a mistake.With regard to refacturing:1. Put the same function in separate functions and procedures, and call if necessary. You. CHEERING a lot of recoding.2. Each function and procedure should ideally be performed One action. 4. Please write comments to the code. Pity other programmers.3. Read the articles on the formatting of the text. Your essay is extremely uncomfortable to read because of the lack of normal resignations. This design killed: if t = 1 then begin
while not f do begin
x:=Random(8)+1;
y:=Random(8)+1;
if not((field.Field[x,y]= cc_fill)or(field.Field[x,y]= cc_miss)or
(field.Field[x,y+1]= cc_fill)or(field.Field[x,y+1]= cc_miss)or
(field.Field[x,y+2]= cc_fill)or(field.Field[x,y+2]= cc_miss)) then f:=true;
end; end else begin
while not f do begin
x:=Random(8)+1;
y:=Random(8)+1;
if not((field.Field[x,y]= cc_fill)or(field.Field[x,y]= cc_miss)or
(field.Field[x+1,y]= cc_fill)or(field.Field[x+1,y]= cc_miss)or
(field.Field[x+2,y]= cc_fill)or(field.Field[x+2,y]= cc_miss)) then f:=true;
end;
end;
Agree that as such, it looks more delicious: if t = 1 then
begin
while not f do
begin
x:=Random(8)+1;
y:=Random(8)+1;
if not((field.Field[x,y]= cc_fill)or(field.Field[x,y]= cc_miss)or
(field.Field[x,y+1]= cc_fill)or(field.Field[x,y+1]= cc_miss)or
(field.Field[x,y+2]= cc_fill)or(field.Field[x,y+2]= cc_miss)) then
f:=true;
end;
end
else
begin
while not f do
begin
x:=Random(8)+1;
y:=Random(8)+1;
if not((field.Field[x,y]= cc_fill)or(field.Field[x,y]= cc_miss)or
(field.Field[x+1,y]= cc_fill)or(field.Field[x+1,y]= cc_miss)or
(field.Field[x+2,y]= cc_fill)or(field.Field[x+2,y]= cc_miss)) then
f:=true;
end;
end;
Yeah, I've got a habit of moving on to a new line with a retreat. They don't argue about taste, as they say. In general, your code is a clear example of how to do Don't.♪ When you lead the architecture and the code format to a normal view, you'll find a mistake.