diff --git a/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs b/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs
index ff298ab..2f8e832 100644
--- a/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs
+++ b/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs
@@ -56,7 +56,6 @@ public abstract class AbstractCompany
{
return company._collection.Insert(warship);
}
-
///
/// Перезагрузка оператора удаления для класса
///
@@ -107,5 +106,4 @@ public abstract class AbstractCompany
/// Расстановка объектов
///
protected abstract void SetObjectsPosition();
-}
-
+}
\ No newline at end of file
diff --git a/Battleship/Battleship/CollectionGenericObjects/ICollectionGenericObjects.cs b/Battleship/Battleship/CollectionGenericObjects/ICollectionGenericObjects.cs
index fb30a96..4cb31a9 100644
--- a/Battleship/Battleship/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/Battleship/Battleship/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -46,4 +46,4 @@ public interface ICollectionGenericObjects
/// Позиция
/// Объект
T? Get(int position);
-}
+}
\ No newline at end of file
diff --git a/Battleship/Battleship/CollectionGenericObjects/MassiveGenericObjects.cs b/Battleship/Battleship/CollectionGenericObjects/MassiveGenericObjects.cs
index f86cc95..fce9967 100644
--- a/Battleship/Battleship/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/Battleship/Battleship/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -64,23 +64,22 @@ public class MassiveGenericObjects : ICollectionGenericObjects
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
if (_collection[position] != null)
- {
+ {
// проверка, что после вставляемого элемента в массиве есть пустой элемент
int nullIndex = -1;
for (int i = position + 1; i < Count; i++)
- {
- if (_collection[i] == null)
{
+ if (_collection[i] == null)
+ {
nullIndex = i;
break;
- }
- ++index;
- }
+ }
+ }
// Если пустого элемента нет, то выходим
if (nullIndex < 0)
{
return -1;
- }
+ }
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
int j = nullIndex - 1;
while (j >= position)
@@ -88,7 +87,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects
_collection[j + 1] = _collection[j];
j--;
}
- position--;
}
// TODO вставка по позиции
_collection[position] = obj;
diff --git a/Battleship/Battleship/CollectionGenericObjects/WarshipSharingService.cs b/Battleship/Battleship/CollectionGenericObjects/WarshipSharingService.cs
index b0943f2..3aca316 100644
--- a/Battleship/Battleship/CollectionGenericObjects/WarshipSharingService.cs
+++ b/Battleship/Battleship/CollectionGenericObjects/WarshipSharingService.cs
@@ -54,7 +54,7 @@ public class WarshipSharingService : AbstractCompany
posWidth = 0;
posHeight--;
}
- if (posHeight < 0)
+ if (posHeight > height)
{
return;
}
diff --git a/Battleship/Battleship/Drawings/DrawingBattleship.cs b/Battleship/Battleship/Drawings/DrawingBattleship.cs
index bb835c3..490fc08 100644
--- a/Battleship/Battleship/Drawings/DrawingBattleship.cs
+++ b/Battleship/Battleship/Drawings/DrawingBattleship.cs
@@ -1,5 +1,4 @@
using Battleship.Entities;
-//using System.Drawings;
namespace Battleship.Drawings;
///
diff --git a/Battleship/Battleship/Drawings/DrawingWarship.cs b/Battleship/Battleship/Drawings/DrawingWarship.cs
index a5afa8f..5d6e271 100644
--- a/Battleship/Battleship/Drawings/DrawingWarship.cs
+++ b/Battleship/Battleship/Drawings/DrawingWarship.cs
@@ -238,7 +238,7 @@ public class DrawingWarship
Brush brBlack = new SolidBrush(Color.Black);
g.FillRectangle(brBlack, _startPosX.Value + 5, _startPosY.Value + 7, 5, 10); //верхний
g.FillRectangle(brBlack, _startPosX.Value + 5, _startPosY.Value + 22, 5, 10); //нижний
- //границы двигателей
+ //границы двигателей
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 7, 5, 10); //двигатель верхний
g.DrawRectangle(pen, _startPosX.Value + 5, _startPosY.Value + 22, 5, 10); //двигатель нижний
diff --git a/Battleship/Battleship/FormWarshipCollection.Designer.cs b/Battleship/Battleship/FormWarshipCollection.Designer.cs
index 235a23d..47b969c 100644
--- a/Battleship/Battleship/FormWarshipCollection.Designer.cs
+++ b/Battleship/Battleship/FormWarshipCollection.Designer.cs
@@ -32,21 +32,21 @@
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveWarship = new Button();
- maskedTextBox = new MaskedTextBox();
buttonAddBattleship = new Button();
buttonAddWarship = new Button();
comboBoxSelectionCompany = new ComboBox();
pictureBox = new PictureBox();
+ maskedTextBox1 = new MaskedTextBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
+ groupBoxTools.Controls.Add(maskedTextBox1);
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonRemoveWarship);
- groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(buttonAddBattleship);
groupBoxTools.Controls.Add(buttonAddWarship);
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
@@ -89,15 +89,7 @@
buttonRemoveWarship.TabIndex = 4;
buttonRemoveWarship.Text = "Удалить корабль";
buttonRemoveWarship.UseVisualStyleBackColor = true;
- //
- // maskedTextBox
- //
- maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- maskedTextBox.Location = new Point(12, 238);
- maskedTextBox.Mask = "00";
- maskedTextBox.Name = "maskedTextBox";
- maskedTextBox.Size = new Size(274, 27);
- maskedTextBox.TabIndex = 3;
+ buttonRemoveWarship.Click += buttonRemoveWarship_Click_1;
//
// buttonAddBattleship
//
@@ -142,6 +134,15 @@
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
+ // maskedTextBox1
+ //
+ maskedTextBox1.Anchor = AnchorStyles.Left | AnchorStyles.Right;
+ maskedTextBox1.Location = new Point(12, 250);
+ maskedTextBox1.Mask = "00";
+ maskedTextBox1.Name = "maskedTextBox1";
+ maskedTextBox1.Size = new Size(274, 27);
+ maskedTextBox1.TabIndex = 7;
+ //
// FormWarshipCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
@@ -151,7 +152,6 @@
Controls.Add(groupBoxTools);
Name = "FormWarshipCollection";
Text = "Коллекция кораблей";
- //Load += this.FormWarshipCollection_Load;
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
@@ -161,13 +161,12 @@
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectionCompany;
- private MaskedTextBox maskedTextBoxPosition;
private Button buttonAddBattleship;
private Button buttonAddWarship;
private Button buttonRemoveWarship;
- private MaskedTextBox maskedTextBox;
private PictureBox pictureBox;
private Button buttonRefresh;
private Button buttonGoToCheck;
+ private MaskedTextBox maskedTextBox1;
}
}
\ No newline at end of file
diff --git a/Battleship/Battleship/FormWarshipCollection.cs b/Battleship/Battleship/FormWarshipCollection.cs
index 6a425c9..21a1d8b 100644
--- a/Battleship/Battleship/FormWarshipCollection.cs
+++ b/Battleship/Battleship/FormWarshipCollection.cs
@@ -55,8 +55,8 @@ public partial class FormWarshipCollection : Form
break;
case nameof(DrawingBattleship):
drawingWarship = new DrawingBattleship(random.Next(100, 300), random.Next(1000, 3000),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
- Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
+ GetColor(random),
+ GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
@@ -149,7 +149,7 @@ public partial class FormWarshipCollection : Form
///
private void buttonRemoveWarship_Click_1(object sender, EventArgs e)
{
- if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
+ if (string.IsNullOrEmpty(maskedTextBox1.Text) || _company == null)
{
return;
}
@@ -159,7 +159,7 @@ public partial class FormWarshipCollection : Form
return;
}
- int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
+ int pos = Convert.ToInt32(maskedTextBox1.Text);
if (_company - pos != null)
{
MessageBox.Show("Объект удален");
@@ -171,36 +171,6 @@ public partial class FormWarshipCollection : Form
}
}
- ///
- /// Передача на тесты
- ///
- ///
- ///
- private void buttonGoToCheck_Click(object sender, EventArgs e)
- {
- if (_company == null)
- {
- return;
- }
-
- DrawingWarship? warship = null;
- int counter = 100;
- while (warship == null)
- {
- warship = _company.GetRandomObject();
- counter--;
- if (counter <= 0)
- {
- break;
- }
- }
-
- FormBattleship form = new FormBattleship();
- form.SetWarship = warship;
- form.ShowDialog();
-
- }
-
///
/// Обновление
///
diff --git a/Battleship/Battleship/MovementStrategy/IMoveableObjectcs.cs b/Battleship/Battleship/MovementStrategy/IMoveableObjectcs.cs
index 913cef6..16dbad9 100644
--- a/Battleship/Battleship/MovementStrategy/IMoveableObjectcs.cs
+++ b/Battleship/Battleship/MovementStrategy/IMoveableObjectcs.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Battleship.MovementStrategy;
+namespace Battleship.MovementStrategy;
public interface IMoveableObjectcs
{