Лабораторная работа №3
This commit is contained in:
parent
3fa56e548d
commit
3ac1dab1c9
@ -56,7 +56,6 @@ public abstract class AbstractCompany
|
|||||||
{
|
{
|
||||||
return company._collection.Insert(warship);
|
return company._collection.Insert(warship);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перезагрузка оператора удаления для класса
|
/// Перезагрузка оператора удаления для класса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -108,4 +107,3 @@ public abstract class AbstractCompany
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void SetObjectsPosition();
|
protected abstract void SetObjectsPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
nullIndex = i;
|
nullIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++index;
|
|
||||||
}
|
}
|
||||||
// Если пустого элемента нет, то выходим
|
// Если пустого элемента нет, то выходим
|
||||||
if (nullIndex < 0)
|
if (nullIndex < 0)
|
||||||
@ -88,7 +87,6 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|||||||
_collection[j + 1] = _collection[j];
|
_collection[j + 1] = _collection[j];
|
||||||
j--;
|
j--;
|
||||||
}
|
}
|
||||||
position--;
|
|
||||||
}
|
}
|
||||||
// TODO вставка по позиции
|
// TODO вставка по позиции
|
||||||
_collection[position] = obj;
|
_collection[position] = obj;
|
||||||
|
@ -54,7 +54,7 @@ public class WarshipSharingService : AbstractCompany
|
|||||||
posWidth = 0;
|
posWidth = 0;
|
||||||
posHeight--;
|
posHeight--;
|
||||||
}
|
}
|
||||||
if (posHeight < 0)
|
if (posHeight > height)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Battleship.Entities;
|
using Battleship.Entities;
|
||||||
//using System.Drawings;
|
|
||||||
|
|
||||||
namespace Battleship.Drawings;
|
namespace Battleship.Drawings;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,21 +32,21 @@
|
|||||||
buttonRefresh = new Button();
|
buttonRefresh = new Button();
|
||||||
buttonGoToCheck = new Button();
|
buttonGoToCheck = new Button();
|
||||||
buttonRemoveWarship = new Button();
|
buttonRemoveWarship = new Button();
|
||||||
maskedTextBox = new MaskedTextBox();
|
|
||||||
buttonAddBattleship = new Button();
|
buttonAddBattleship = new Button();
|
||||||
buttonAddWarship = new Button();
|
buttonAddWarship = new Button();
|
||||||
comboBoxSelectionCompany = new ComboBox();
|
comboBoxSelectionCompany = new ComboBox();
|
||||||
pictureBox = new PictureBox();
|
pictureBox = new PictureBox();
|
||||||
|
maskedTextBox1 = new MaskedTextBox();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
groupBoxTools.Controls.Add(maskedTextBox1);
|
||||||
groupBoxTools.Controls.Add(buttonRefresh);
|
groupBoxTools.Controls.Add(buttonRefresh);
|
||||||
groupBoxTools.Controls.Add(buttonGoToCheck);
|
groupBoxTools.Controls.Add(buttonGoToCheck);
|
||||||
groupBoxTools.Controls.Add(buttonRemoveWarship);
|
groupBoxTools.Controls.Add(buttonRemoveWarship);
|
||||||
groupBoxTools.Controls.Add(maskedTextBox);
|
|
||||||
groupBoxTools.Controls.Add(buttonAddBattleship);
|
groupBoxTools.Controls.Add(buttonAddBattleship);
|
||||||
groupBoxTools.Controls.Add(buttonAddWarship);
|
groupBoxTools.Controls.Add(buttonAddWarship);
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
|
groupBoxTools.Controls.Add(comboBoxSelectionCompany);
|
||||||
@ -89,15 +89,7 @@
|
|||||||
buttonRemoveWarship.TabIndex = 4;
|
buttonRemoveWarship.TabIndex = 4;
|
||||||
buttonRemoveWarship.Text = "Удалить корабль";
|
buttonRemoveWarship.Text = "Удалить корабль";
|
||||||
buttonRemoveWarship.UseVisualStyleBackColor = true;
|
buttonRemoveWarship.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonRemoveWarship.Click += buttonRemoveWarship_Click_1;
|
||||||
// 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;
|
|
||||||
//
|
//
|
||||||
// buttonAddBattleship
|
// buttonAddBattleship
|
||||||
//
|
//
|
||||||
@ -142,6 +134,15 @@
|
|||||||
pictureBox.TabIndex = 1;
|
pictureBox.TabIndex = 1;
|
||||||
pictureBox.TabStop = false;
|
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
|
// FormWarshipCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -151,7 +152,6 @@
|
|||||||
Controls.Add(groupBoxTools);
|
Controls.Add(groupBoxTools);
|
||||||
Name = "FormWarshipCollection";
|
Name = "FormWarshipCollection";
|
||||||
Text = "Коллекция кораблей";
|
Text = "Коллекция кораблей";
|
||||||
//Load += this.FormWarshipCollection_Load;
|
|
||||||
groupBoxTools.ResumeLayout(false);
|
groupBoxTools.ResumeLayout(false);
|
||||||
groupBoxTools.PerformLayout();
|
groupBoxTools.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
@ -161,13 +161,12 @@
|
|||||||
|
|
||||||
private GroupBox groupBoxTools;
|
private GroupBox groupBoxTools;
|
||||||
private ComboBox comboBoxSelectionCompany;
|
private ComboBox comboBoxSelectionCompany;
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
|
||||||
private Button buttonAddBattleship;
|
private Button buttonAddBattleship;
|
||||||
private Button buttonAddWarship;
|
private Button buttonAddWarship;
|
||||||
private Button buttonRemoveWarship;
|
private Button buttonRemoveWarship;
|
||||||
private MaskedTextBox maskedTextBox;
|
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
private Button buttonRefresh;
|
private Button buttonRefresh;
|
||||||
private Button buttonGoToCheck;
|
private Button buttonGoToCheck;
|
||||||
|
private MaskedTextBox maskedTextBox1;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,8 +55,8 @@ public partial class FormWarshipCollection : Form
|
|||||||
break;
|
break;
|
||||||
case nameof(DrawingBattleship):
|
case nameof(DrawingBattleship):
|
||||||
drawingWarship = new DrawingBattleship(random.Next(100, 300), random.Next(1000, 3000),
|
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)),
|
GetColor(random),
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
GetColor(random),
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -149,7 +149,7 @@ public partial class FormWarshipCollection : Form
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonRemoveWarship_Click_1(object sender, EventArgs e)
|
private void buttonRemoveWarship_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
if (string.IsNullOrEmpty(maskedTextBox1.Text) || _company == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ public partial class FormWarshipCollection : Form
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBox1.Text);
|
||||||
if (_company - pos != null)
|
if (_company - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
@ -171,36 +171,6 @@ public partial class FormWarshipCollection : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Передача на тесты
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновление
|
/// Обновление
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace Battleship.MovementStrategy;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Battleship.MovementStrategy;
|
|
||||||
|
|
||||||
public interface IMoveableObjectcs
|
public interface IMoveableObjectcs
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user