diff --git a/ProjectBattleship/ProjectBattleship/BlockEnum.cs b/ProjectBattleship/ProjectBattleship/BlockEnum.cs
new file mode 100644
index 0000000..5cfba2d
--- /dev/null
+++ b/ProjectBattleship/ProjectBattleship/BlockEnum.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBattleship;
+
+public enum BlockEnum
+{
+ Two,
+ Four,
+ Six
+}
diff --git a/ProjectBattleship/ProjectBattleship/DrawingBattleship.cs b/ProjectBattleship/ProjectBattleship/DrawingBattleship.cs
index 4f60cf7..2be6770 100644
--- a/ProjectBattleship/ProjectBattleship/DrawingBattleship.cs
+++ b/ProjectBattleship/ProjectBattleship/DrawingBattleship.cs
@@ -4,6 +4,7 @@
///
public class DrawingBattleship
{
+ public DrawingBlock Block { get; set; }
///
/// Класс-сущность
///
@@ -51,6 +52,7 @@ public class DrawingBattleship
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
+ Block = new DrawingBlock();
}
///
/// Установка границ поля
@@ -225,5 +227,7 @@ public class DrawingBattleship
g.DrawRectangle(pen, _startPosX.Value + 119,
_startPosY.Value + 24, 12, 2);
}
+
+ Block.DrawBlocks(g, _startPosX, _startPosY);
}
}
\ No newline at end of file
diff --git a/ProjectBattleship/ProjectBattleship/DrawingBlock.cs b/ProjectBattleship/ProjectBattleship/DrawingBlock.cs
new file mode 100644
index 0000000..60dcba6
--- /dev/null
+++ b/ProjectBattleship/ProjectBattleship/DrawingBlock.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectBattleship;
+
+public class DrawingBlock
+{
+ public BlockEnum BlockNum;
+ public int NumOfBlocks
+ {
+ set
+ {
+ switch (value)
+ {
+ case 0:
+ BlockNum = BlockEnum.Two;
+ break;
+ case 1:
+ BlockNum = BlockEnum.Four;
+ break;
+ case 2:
+ BlockNum = BlockEnum.Six;
+ break;
+ default:
+ BlockNum = BlockEnum.Two;
+ break;
+ }
+ }
+ }
+ public void DrawBlocks(Graphics g, int? _startPosX, int? _startPosY)
+ {
+ Brush blocksColor = new SolidBrush(Color.Orange);
+
+ g.FillRectangle(blocksColor, _startPosX.Value + 10,
+ _startPosY.Value , 10, 10);
+ g.FillRectangle(blocksColor, _startPosX.Value + 10,
+ _startPosY.Value+40, 10, 10);
+ if (BlockNum == BlockEnum.Four || BlockNum == BlockEnum.Six)
+ {
+ g.FillRectangle(blocksColor, _startPosX.Value + 30,
+ _startPosY.Value, 10, 10);
+ g.FillRectangle(blocksColor, _startPosX.Value + 30,
+ _startPosY.Value + 40, 10, 10);
+ }
+
+ if (BlockNum == BlockEnum.Six)
+ {
+ g.FillRectangle(blocksColor, _startPosX.Value + 50,
+ _startPosY.Value, 10, 10);
+ g.FillRectangle(blocksColor, _startPosX.Value + 50,
+ _startPosY.Value + 40, 10, 10);
+ }
+
+ }
+}
diff --git a/ProjectBattleship/ProjectBattleship/FormBattleship.cs b/ProjectBattleship/ProjectBattleship/FormBattleship.cs
index 2e191eb..169fccc 100644
--- a/ProjectBattleship/ProjectBattleship/FormBattleship.cs
+++ b/ProjectBattleship/ProjectBattleship/FormBattleship.cs
@@ -48,6 +48,7 @@ public partial class FormBattleship : Form
pictureBoxBattleship.Height);
_drawingBattleship.SetPosition(random.Next(10, 100),
random.Next(10, 100));
+ _drawingBattleship.Block.NumOfBlocks = random.Next(0, 3);
Draw();
}
///