From 7e69a5b27b76e7e51d663db2386e5ce8d0551056 Mon Sep 17 00:00:00 2001 From: Osyagina_Anna Date: Wed, 1 May 2024 21:30:32 +0400 Subject: [PATCH 1/6] LabWork06 --- .../ListGenericObjects.cs | 17 ------- .../StorageCollection.cs | 19 ++------ .../Drownings/DrawningBoat.cs | 11 ++--- .../Drownings/DrawningMotorboat.cs | 4 +- .../Drownings/ExtentionDrawningBoat.cs | 15 ------ .../ProjectMotorboat/Entities/EntityBoat.cs | 6 --- .../ProjectMotorboat/FormBoatCollection.cs | 47 +------------------ .../ProjectMotorboat/FormBoatConfig.cs | 4 +- ProjectMotorboat/ProjectMotorboat/Program.cs | 4 +- 9 files changed, 16 insertions(+), 111 deletions(-) diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs index 370d8c8..f9cfbe5 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs @@ -10,16 +10,10 @@ public class ListGenericObjects : ICollectionGenericObjects where T : class { - /// - /// Список объектов, которые храним - /// private readonly List _collection; public CollectionType GetCollectionType => CollectionType.List; - /// - /// Максимально допустимое число объектов в списке - /// private int _maxCount; public int Count => _collection.Count; @@ -39,9 +33,6 @@ where T : class } } - /// - /// Конструктор - /// public ListGenericObjects() { _collection = new(); @@ -49,15 +40,12 @@ where T : class public T? Get(int position) { - // TODO проверка позиции if (position >= Count || position < 0) return null; return _collection[position]; } public int Insert(T obj) { - // TODO проверка, что не превышено максимальное количество элементов - // TODO вставка в конец набора if (Count + 1 > _maxCount) return -1; _collection.Add(obj); return Count; @@ -65,9 +53,6 @@ where T : class public int Insert(T obj, int position) { - // TODO проверка, что не превышено максимальное количество элементов - // TODO проверка позиции - // TODO вставка по позиции if (Count + 1 > _maxCount) return -1; if (position < 0 || position > Count) return -1; _collection.Insert(position, obj); @@ -76,8 +61,6 @@ where T : class public T? Remove(int position) { - // TODO проверка позиции - // TODO удаление объекта из списка if (position < 0 || position > Count) return null; T? pos = _collection[position]; _collection.RemoveAt(position); diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs index bb19f7c..bcd556a 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs @@ -23,8 +23,7 @@ public class StorageCollection public void AddCollection(string name, CollectionType collectionType) { - // TODO проверка, что name не пустой и нет в словаре записи с таким ключом - // TODO Прописать логику для добавления + if (name == null || _storages.ContainsKey(name)) { return; } switch (collectionType) @@ -43,7 +42,7 @@ public class StorageCollection public void DelCollection(string name) { - // TODO Прописать логику для удаления коллекции + if (_storages.ContainsKey(name)) _storages.Remove(name); } @@ -53,7 +52,7 @@ public class StorageCollection { get { - // TODO Продумать логику получения объекта + if (name == null || !_storages.ContainsKey(name)) { return null; } return _storages[name]; } @@ -65,11 +64,7 @@ public class StorageCollection private readonly string _separatorItems = ";"; - /// - /// Сохранение информации в хранилище в файл - /// - /// Путь и имя файла - /// true - сохранение прошло успешно, false - ошибка при сохранении данных + public bool SaveData(string filename) { if (_storages.Count == 0) @@ -118,11 +113,7 @@ public class StorageCollection return true; } - /// - /// Загрузка информации в хранилище из файла - /// - /// Путь и имя файла - /// true - загрузка прошла успешно, false - ошибка при загрузке данных + public bool LoadData(string filename) { if (!File.Exists(filename)) diff --git a/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs b/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs index 9c9321a..8a6c937 100644 --- a/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs @@ -114,28 +114,28 @@ public class DrawningBoat } switch (direction) { - //влево + case DirectionType.Left: if (_startPosX.Value - EntityBoat.Step > 0) { _startPosX -= (int)EntityBoat.Step; } return true; - //вверх + case DirectionType.Up: if (_startPosY.Value - EntityBoat.Step > 0) { _startPosY -= (int)EntityBoat.Step; } return true; - // вправо + case DirectionType.Right: if (_startPosX.Value + EntityBoat.Step + _drawningBoatWidth < _pictureWidth) { _startPosX += (int)EntityBoat.Step; } return true; - //вниз + case DirectionType.Down: if (_startPosY.Value + EntityBoat.Step + _drawningBoatHeight < _pictureHeight) { @@ -155,7 +155,7 @@ public class DrawningBoat Pen pen = new(Color.Black); Brush mainBrush = new SolidBrush(EntityBoat.BodyColor); - // корпус + Point[] hull = new Point[] { new Point(_startPosX.Value + 5, _startPosY.Value + 0), @@ -167,7 +167,6 @@ public class DrawningBoat g.FillPolygon(mainBrush, hull); g.DrawPolygon(pen, hull); - // основная часть Brush blockBrush = new SolidBrush(EntityBoat.BodyColor); g.FillRectangle(blockBrush, _startPosX.Value + 20, _startPosY.Value + 15, 80, 40); g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 15, 80, 40); diff --git a/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningMotorboat.cs b/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningMotorboat.cs index fcda9e0..a4c54fd 100644 --- a/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningMotorboat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningMotorboat.cs @@ -27,14 +27,14 @@ public class DrawningMotorboat : DrawningBoat base.DrawTransport(g); - // стекло впереди + if (motorboat.Glass) { Brush glassBrush = new SolidBrush(Color.LightBlue); g.FillEllipse(glassBrush, _startPosX.Value + 20, _startPosY.Value + 15, 100, 40); g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 15, 100, 40); } - // двигатель + if (motorboat.Motor) { Brush engineBrush = new diff --git a/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs b/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs index 93a04ba..39a31be 100644 --- a/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs @@ -8,16 +8,7 @@ using System.Threading.Tasks; namespace ProjectMotorboat.Drownings; public static class ExtentionDrawningBoat { - /// - /// Разделитель для записи информации по объекту в файл - /// private static readonly string _separatorForObject = ":"; - - /// - /// Создание объекта из строки - /// - /// - /// public static DrawningBoat? CreateDrawningBoat(this string info) { string[] strs = info.Split(_separatorForObject); @@ -34,12 +25,6 @@ public static class ExtentionDrawningBoat } return null; } - - /// - /// Получение данных для сохранения в файл - /// - /// - /// public static string GetDataForSave(this DrawningBoat drawningBoat) { string[]? array = drawningBoat?.EntityBoat?.GetStringRepresentation(); diff --git a/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs b/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs index d386dc6..9dfd7c1 100644 --- a/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs @@ -30,12 +30,6 @@ public class EntityBoat { return new[] { nameof(EntityBoat), Speed.ToString(), Weight.ToString(), BodyColor.Name }; } - - /// - /// Создание объекта из строки - /// - /// - /// public static EntityBoat? CreateEntityBoat(string[] strs) { if (strs.Length != 4 || strs[0] != nameof(EntityBoat)) diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs index d127340..ddfc166 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs @@ -3,47 +3,24 @@ using ProjectMotorboat.Drownings; using System.Windows.Forms; namespace ProjectMotorboat; - -/// -/// Форма работы с компанией и ее коллекцией -/// public partial class FormBoatCollection : Form { private readonly StorageCollection _storageCollection; - /// - /// Компания - /// private AbstractCompany? _company = null; - - /// - /// Конструктор - /// public FormBoatCollection() { InitializeComponent(); _storageCollection = new(); } - - /// - /// Выбор компании - /// - /// - /// private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e) { panelCompanyTools.Enabled = false; } - - /// - /// Добавление обычного автомобиля - /// - /// - /// private void ButtonAddBoat_Click(object sender, EventArgs e) { FormBoatConfig form = new(); - // TODO передать метод + form.AddEvent(SetBoat); form.Show(); @@ -67,18 +44,6 @@ public partial class FormBoatCollection : Form } - - - /// - /// Создание объекта класса-перемещения - /// - /// Тип создаваемого объекта - - /// - /// Удаление объекта - /// - /// - /// private void ButtonRemoveBoat_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) @@ -103,11 +68,6 @@ public partial class FormBoatCollection : Form } } - /// - /// Передача объекта в другую форму - /// - /// - /// private void ButtonGoToCheck_Click(object sender, EventArgs e) { if (_company == null) @@ -139,11 +99,6 @@ public partial class FormBoatCollection : Form form.ShowDialog(); } - /// - /// Перерисовка коллекции - /// - /// - /// private void ButtonRefresh_Click(object sender, EventArgs e) { if (_company == null) diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs index cdcba04..355f037 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs @@ -81,11 +81,11 @@ namespace ProjectMotorboat private void Panel_MouseDown(object? sender, MouseEventArgs e) { - // TODO отправка цвета в Drag&Drop + (sender as Control)?.DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); } - // Логика смены цветов: основного и дополнительного (для продвинутого объекта) + private void LabelBodyColor_DragEnter(object sender, DragEventArgs e) { if (e.Data?.GetDataPresent(typeof(Color)) ?? false) diff --git a/ProjectMotorboat/ProjectMotorboat/Program.cs b/ProjectMotorboat/ProjectMotorboat/Program.cs index 0c67735..2bbdd34 100644 --- a/ProjectMotorboat/ProjectMotorboat/Program.cs +++ b/ProjectMotorboat/ProjectMotorboat/Program.cs @@ -2,9 +2,7 @@ namespace ProjectMotorboat { internal static class Program { - /// - /// The main entry point for the application. - /// + [STAThread] static void Main() { From 7d02ac089f912c5fb8582b6c1e22d8bc7c06ec11 Mon Sep 17 00:00:00 2001 From: Osyagina_Anna Date: Wed, 1 May 2024 21:32:46 +0400 Subject: [PATCH 2/6] LabWork06 --- ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs | 9 --------- .../ProjectMotorboat/MovementStrategy/MoveToBorder.cs | 7 +------ .../ProjectMotorboat/MovementStrategy/MoveToCenter.cs | 7 +------ .../MovementStrategy/ObjectParameters.cs | 7 +------ .../ProjectMotorboat/MovementStrategy/StrategyStatus.cs | 8 +------- 5 files changed, 4 insertions(+), 34 deletions(-) diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs index 355f037..8de01e3 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatConfig.cs @@ -1,14 +1,5 @@ using ProjectMotorboat.Drownings; using ProjectMotorboat.Entities; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; namespace ProjectMotorboat { diff --git a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToBorder.cs b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToBorder.cs index 3da281d..9004dfc 100644 --- a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToBorder.cs +++ b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToBorder.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace ProjectMotorboat.MovementStrategy; public class MoveToBorder : AbstractStrategy { diff --git a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToCenter.cs b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToCenter.cs index 08b425a..7538fc1 100644 --- a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToCenter.cs +++ b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/MoveToCenter.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace ProjectMotorboat.MovementStrategy; public class MoveToCenter : AbstractStrategy { diff --git a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/ObjectParameters.cs b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/ObjectParameters.cs index 51bb02b..2393d1a 100644 --- a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/ObjectParameters.cs +++ b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/ObjectParameters.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace ProjectMotorboat.MovementStrategy; public class ObjectParameters diff --git a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/StrategyStatus.cs b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/StrategyStatus.cs index e4b58f8..94acac8 100644 --- a/ProjectMotorboat/ProjectMotorboat/MovementStrategy/StrategyStatus.cs +++ b/ProjectMotorboat/ProjectMotorboat/MovementStrategy/StrategyStatus.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectMotorboat.MovementStrategy; +namespace ProjectMotorboat.MovementStrategy; public enum StrategyStatus { From 974a8675b428c75a5c9870b503e0e2725ff641ae Mon Sep 17 00:00:00 2001 From: Osyagina_Anna Date: Wed, 1 May 2024 21:36:42 +0400 Subject: [PATCH 3/6] LabWork06 --- ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs | 6 ------ .../CollectionGenericObjects/AbstractCompany.cs | 3 +-- .../CollectionGenericObjects/CollectionType.cs | 7 +------ .../CollectionGenericObjects/HarborService.cs | 2 +- .../CollectionGenericObjects/ICollectionGenericObjects.cs | 7 +------ .../CollectionGenericObjects/ListGenericObjects.cs | 8 +------- .../CollectionGenericObjects/MassiveGenericObjects.cs | 4 +--- .../CollectionGenericObjects/StorageCollection.cs | 4 ---- .../ProjectMotorboat/Drownings/DirectionType.cs | 7 +------ .../ProjectMotorboat/Drownings/DrawningBoat.cs | 6 ------ .../ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs | 5 ----- ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs | 8 +------- ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs | 1 - 13 files changed, 8 insertions(+), 60 deletions(-) diff --git a/ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs b/ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs index d7c5e5d..dc0416c 100644 --- a/ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs +++ b/ProjectMotorboat/ProjectMotorboat/BoatDelegate.cs @@ -1,10 +1,4 @@ using ProjectMotorboat.Drownings; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ProjectMotorboat; public delegate void BoatDelegate(DrawningBoat car); \ No newline at end of file diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/AbstractCompany.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/AbstractCompany.cs index 128367e..c7ad6bf 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/AbstractCompany.cs @@ -1,5 +1,4 @@ -using ProjectMotorboat.CollectionGenericObjects; -using ProjectMotorboat.Drownings; +using ProjectMotorboat.Drownings; namespace ProjectMotorboat.CollectionGenericObjects; diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs index eb3ec09..5d33f5c 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/CollectionType.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace ProjectMotorboat.CollectionGenericObjects; public enum CollectionType diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/HarborService.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/HarborService.cs index be39f68..92b0618 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/HarborService.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/HarborService.cs @@ -1,4 +1,4 @@ -using ProjectMotorboat.CollectionGenericObjects; + using ProjectMotorboat.Drownings; namespace ProjectMotorboat.CollectionGenericObjects; diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ICollectionGenericObjects.cs index 155355d..21b201c 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace ProjectMotorboat.CollectionGenericObjects; public interface ICollectionGenericObjects diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs index f9cfbe5..0a0c710 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/ListGenericObjects.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectMotorboat.CollectionGenericObjects; +namespace ProjectMotorboat.CollectionGenericObjects; public class ListGenericObjects : ICollectionGenericObjects diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/MassiveGenericObjects.cs index 6047760..4eef7ae 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/MassiveGenericObjects.cs @@ -1,6 +1,4 @@ - - -namespace ProjectMotorboat.CollectionGenericObjects; +namespace ProjectMotorboat.CollectionGenericObjects; public class MassiveGenericObjects : ICollectionGenericObjects where T : class { diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs index bcd556a..c83a440 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs @@ -1,9 +1,5 @@ using ProjectMotorboat.Drownings; -using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace ProjectMotorboat.CollectionGenericObjects; diff --git a/ProjectMotorboat/ProjectMotorboat/Drownings/DirectionType.cs b/ProjectMotorboat/ProjectMotorboat/Drownings/DirectionType.cs index 1741509..5ef15f9 100644 --- a/ProjectMotorboat/ProjectMotorboat/Drownings/DirectionType.cs +++ b/ProjectMotorboat/ProjectMotorboat/Drownings/DirectionType.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace ProjectMotorboat.Drownings { public enum DirectionType diff --git a/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs b/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs index 8a6c937..d117ab8 100644 --- a/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Drownings/DrawningBoat.cs @@ -1,10 +1,4 @@ using ProjectMotorboat.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace ProjectMotorboat.Drownings; public class DrawningBoat diff --git a/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs b/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs index 39a31be..4106627 100644 --- a/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Drownings/ExtentionDrawningBoat.cs @@ -1,9 +1,4 @@ using ProjectMotorboat.Entities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace ProjectMotorboat.Drownings; public static class ExtentionDrawningBoat diff --git a/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs b/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs index 9dfd7c1..d588e23 100644 --- a/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs +++ b/ProjectMotorboat/ProjectMotorboat/Entities/EntityBoat.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectMotorboat.Entities; +namespace ProjectMotorboat.Entities; public class EntityBoat { diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs index ddfc166..13dc2d2 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.cs @@ -1,6 +1,5 @@ using ProjectMotorboat.CollectionGenericObjects; using ProjectMotorboat.Drownings; -using System.Windows.Forms; namespace ProjectMotorboat; public partial class FormBoatCollection : Form From 655d98ab2904771462a3aa78841ff9851380455b Mon Sep 17 00:00:00 2001 From: Osyagina_Anna Date: Wed, 1 May 2024 21:53:54 +0400 Subject: [PATCH 4/6] LabWork06 --- .../FormBoatCollection.Designer.cs | 24 +++++++++---------- .../ProjectMotorboat/FormBoatCollection.resx | 3 +++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs index df9c8a7..4936ba7 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.Designer.cs @@ -66,9 +66,9 @@ groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Dock = DockStyle.Right; - groupBoxTools.Location = new Point(1027, 28); + groupBoxTools.Location = new Point(1096, 28); groupBoxTools.Name = "groupBoxTools"; - groupBoxTools.Size = new Size(231, 718); + groupBoxTools.Size = new Size(231, 793); groupBoxTools.TabIndex = 0; groupBoxTools.TabStop = false; groupBoxTools.Text = "Инструменты"; @@ -82,15 +82,15 @@ panelCompanyTools.Controls.Add(buttonGoToCheck); panelCompanyTools.Dock = DockStyle.Bottom; panelCompanyTools.Enabled = false; - panelCompanyTools.Location = new Point(3, 390); + panelCompanyTools.Location = new Point(3, 486); panelCompanyTools.Name = "panelCompanyTools"; - panelCompanyTools.Size = new Size(225, 325); + panelCompanyTools.Size = new Size(225, 304); panelCompanyTools.TabIndex = 7; // // buttonAddBoat // buttonAddBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonAddBoat.Location = new Point(3, 3); + buttonAddBoat.Location = new Point(6, 7); buttonAddBoat.Name = "buttonAddBoat"; buttonAddBoat.Size = new Size(219, 54); buttonAddBoat.TabIndex = 1; @@ -100,7 +100,7 @@ // // maskedTextBox // - maskedTextBox.Location = new Point(3, 123); + maskedTextBox.Location = new Point(3, 67); maskedTextBox.Mask = "00"; maskedTextBox.Name = "maskedTextBox"; maskedTextBox.Size = new Size(219, 27); @@ -110,7 +110,7 @@ // buttonRefresh // buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonRefresh.Location = new Point(3, 276); + buttonRefresh.Location = new Point(3, 220); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(219, 54); buttonRefresh.TabIndex = 6; @@ -121,7 +121,7 @@ // buttonDelBoat // buttonDelBoat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonDelBoat.Location = new Point(3, 156); + buttonDelBoat.Location = new Point(3, 100); buttonDelBoat.Name = "buttonDelBoat"; buttonDelBoat.Size = new Size(222, 54); buttonDelBoat.TabIndex = 4; @@ -132,7 +132,7 @@ // buttonGoToCheck // buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; - buttonGoToCheck.Location = new Point(3, 216); + buttonGoToCheck.Location = new Point(3, 160); buttonGoToCheck.Name = "buttonGoToCheck"; buttonGoToCheck.Size = new Size(219, 54); buttonGoToCheck.TabIndex = 5; @@ -248,7 +248,7 @@ pictureBox.Dock = DockStyle.Fill; pictureBox.Location = new Point(0, 28); pictureBox.Name = "pictureBox"; - pictureBox.Size = new Size(1027, 718); + pictureBox.Size = new Size(1096, 793); pictureBox.TabIndex = 1; pictureBox.TabStop = false; // @@ -258,7 +258,7 @@ menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1258, 28); + menuStrip.Size = new Size(1327, 28); menuStrip.TabIndex = 2; menuStrip.Text = "menuStrip"; // @@ -293,7 +293,7 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1258, 746); + ClientSize = new Size(1327, 821); Controls.Add(pictureBox); Controls.Add(groupBoxTools); Controls.Add(menuStrip); diff --git a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.resx b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.resx index ee1748a..a4f11d6 100644 --- a/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.resx +++ b/ProjectMotorboat/ProjectMotorboat/FormBoatCollection.resx @@ -126,4 +126,7 @@ 310, 17 + + 25 + \ No newline at end of file From 0e05120ff49c89b0bc7e43e9b8f9510752483b4a Mon Sep 17 00:00:00 2001 From: Osyagina_Anna Date: Thu, 2 May 2024 09:56:05 +0400 Subject: [PATCH 5/6] LabWork06 --- .../CollectionGenericObjects/StorageCollection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs index c83a440..5652781 100644 --- a/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectMotorboat/ProjectMotorboat/CollectionGenericObjects/StorageCollection.cs @@ -146,9 +146,9 @@ public class StorageCollection string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries); foreach (string elem in set) { - if (elem?.CreateDrawningBoat() is T militaryAircraft) + if (elem?.CreateDrawningBoat() is T boat) { - if (collection.Insert(militaryAircraft) == -1) + if (collection.Insert(boat) == -1) { return false; } From 4f43659d979f6e9d105fc21402ce16c48a0e0200 Mon Sep 17 00:00:00 2001 From: Osyagina_Anna Date: Thu, 2 May 2024 10:08:18 +0400 Subject: [PATCH 6/6] LabWork06 --- ConsoleApp1/ConsoleApp1.sln | 31 ----- ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj | 10 -- ConsoleApp1/ConsoleApp1/Program.cs | 68 ---------- ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj | 10 -- ConsoleApp1/ConsoleApp2/Program.cs | 113 ----------------- LAB02/02/02.csproj | 11 -- LAB02/02/Program.cs | 58 --------- LAB02/03/03.csproj | 11 -- LAB02/03/Program.cs | 1 - LAB02/1/1.csproj | 39 ------ LAB02/1/Program.cs | 2 - LAB02/2/2.csproj | 11 -- LAB02/2/Program.cs | 81 ------------ LAB02/3.1/3.1.csproj | 11 -- LAB02/3.1/Program.cs | 39 ------ LAB02/3/3.csproj | 11 -- LAB02/3/Program.cs | 42 ------ LAB02/LAB02.sln | 56 -------- LAB02/LAB02/LAB02.csproj | 10 -- LAB02/LAB02/Program.cs | 56 -------- WinFormsApp1/WinFormsApp1.sln | 25 ---- WinFormsApp1/WinFormsApp1/Form1.Designer.cs | 39 ------ WinFormsApp1/WinFormsApp1/Form1.cs | 10 -- WinFormsApp1/WinFormsApp1/Form1.resx | 120 ------------------ WinFormsApp1/WinFormsApp1/Program.cs | 17 --- WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj | 11 -- 26 files changed, 893 deletions(-) delete mode 100644 ConsoleApp1/ConsoleApp1.sln delete mode 100644 ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj delete mode 100644 ConsoleApp1/ConsoleApp1/Program.cs delete mode 100644 ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj delete mode 100644 ConsoleApp1/ConsoleApp2/Program.cs delete mode 100644 LAB02/02/02.csproj delete mode 100644 LAB02/02/Program.cs delete mode 100644 LAB02/03/03.csproj delete mode 100644 LAB02/03/Program.cs delete mode 100644 LAB02/1/1.csproj delete mode 100644 LAB02/1/Program.cs delete mode 100644 LAB02/2/2.csproj delete mode 100644 LAB02/2/Program.cs delete mode 100644 LAB02/3.1/3.1.csproj delete mode 100644 LAB02/3.1/Program.cs delete mode 100644 LAB02/3/3.csproj delete mode 100644 LAB02/3/Program.cs delete mode 100644 LAB02/LAB02.sln delete mode 100644 LAB02/LAB02/LAB02.csproj delete mode 100644 LAB02/LAB02/Program.cs delete mode 100644 WinFormsApp1/WinFormsApp1.sln delete mode 100644 WinFormsApp1/WinFormsApp1/Form1.Designer.cs delete mode 100644 WinFormsApp1/WinFormsApp1/Form1.cs delete mode 100644 WinFormsApp1/WinFormsApp1/Form1.resx delete mode 100644 WinFormsApp1/WinFormsApp1/Program.cs delete mode 100644 WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj diff --git a/ConsoleApp1/ConsoleApp1.sln b/ConsoleApp1/ConsoleApp1.sln deleted file mode 100644 index 2ba4487..0000000 --- a/ConsoleApp1/ConsoleApp1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Release|Any CPU.Build.0 = Release|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {3368BA78-2800-49EC-9A71-865DC3C2F15F} - EndGlobalSection -EndGlobal diff --git a/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj deleted file mode 100644 index 2150e37..0000000 --- a/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/ConsoleApp1/ConsoleApp1/Program.cs b/ConsoleApp1/ConsoleApp1/Program.cs deleted file mode 100644 index 16bb850..0000000 --- a/ConsoleApp1/ConsoleApp1/Program.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Collections; -using System; - -// Класс компонента компьютера -public class ComputerComponent -{ - public string Name { get; set; } - public string Type { get; set; } - - public ComputerComponent(string name, string type) - { - Name = name; - Type = type; - } -} - -// АТД Очередь на основе массива -public class CustomQueue -{ - private ArrayList elements = new ArrayList(); - - public int Count { get { return elements.Count; } } - - public void Enqueue(ComputerComponent component) - { - elements.Add(component); - } - - public ComputerComponent Dequeue() - { - if (elements.Count == 0) - { - throw new InvalidOperationException("Queue is empty"); - } - - ComputerComponent component = (ComputerComponent)elements[0]; - elements.RemoveAt(0); - return component; - } - - public ComputerComponent Peek() - { - if (elements.Count == 0) - { - throw new InvalidOperationException("Queue is empty"); - } - - return (ComputerComponent)elements[0]; - } -} -class Program -{ - public static void Main(string[] args) - { - CustomQueue queue = new CustomQueue(); - - // Добавление компонентов в очередь - ComputerComponent cpu = new ComputerComponent("Intel Core i7", "CPU"); - ComputerComponent gpu = new ComputerComponent("Nvidia RTX 3080", "GPU"); - - queue.Enqueue(cpu); - queue.Enqueue(gpu); - - // Проверка совместимости компонентов в сборке - Console.WriteLine("Первый компонент в очереди: {0} ({1})", queue.Peek().Name, queue.Peek().Type); - Console.WriteLine("Извлечен компонент из очереди: {0} ({1})", queue.Dequeue().Name, queue.Dequeue().Type); - } -} diff --git a/ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj b/ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj deleted file mode 100644 index 2150e37..0000000 --- a/ConsoleApp1/ConsoleApp2/ConsoleApp2.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/ConsoleApp1/ConsoleApp2/Program.cs b/ConsoleApp1/ConsoleApp2/Program.cs deleted file mode 100644 index ae6071b..0000000 --- a/ConsoleApp1/ConsoleApp2/Program.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; - -// Реализация АТД Очередь -public class Queue -{ - private T[] elements; - private int front, rear, size, capacity; - - public Queue(int capacity) - { - this.capacity = capacity; - elements = new T[capacity]; - front = size = 0; - rear = capacity - 1; - } - - public void Enqueue(T item) - { - if (size == capacity) - throw new Exception("Queue is full"); - rear = (rear + 1) % capacity; - elements[rear] = item; - size++; - } - - public T Dequeue() - { - if (size == 0) - throw new Exception("Queue is empty"); - T item = elements[front]; - front = (front + 1) % capacity; - size--; - return item; - } - - // Реализация СД Массив - public static void SelectionSort(int[] array) - { - for (int i = 0; i < array.Length - 1; i++) - { - int minIndex = i; - for (int j = i + 1; j < array.Length; j++) - { - if (array[j] < array[minIndex]) - { - minIndex = j; - } - } - if (minIndex != i) - { - int temp = array[i]; - array[i] = array[minIndex]; - array[minIndex] = temp; - } - } - } - - // Быстрая сортировка - public static void QuickSort(int[] array, int left, int right) - { - if (left < right) - { - int pivot = Partition(array, left, right); - QuickSort(array, left, pivot - 1); - QuickSort(array, pivot + 1, right); - } - } - - private static int Partition(int[] array, int left, int right) - { - int pivot = array[right]; - int i = left - 1; - for (int j = left; j < right; j++) - { - if (array[j] < pivot) - { - i++; - int temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - } - int temp1 = array[i + 1]; - array[i + 1] = array[right]; - array[right] = temp1; - return i + 1; - } - - public static void Main() - { - int[] array = { 64, 34, 25, 12, 22, 11, 90 }; - - // Сортировка выбором - Console.WriteLine("Before selection sort:"); - foreach (var item in array) Console.Write(item + " "); - SelectionSort(array); - Console.WriteLine("\n\nAfter selection sort:"); - foreach (var item in array) Console.Write(item + " "); - - // Быстрая сортировка - Console.WriteLine("\n\nBefore quick sort:"); - foreach (var item in array) Console.Write(item + " "); - QuickSort(array, 0, array.Length - 1); - Console.WriteLine("\n\nAfter quick sort:"); - foreach (var item in array) Console.Write(item + " "); - - // Использование Очереди - Queue queue = new Queue(5); - queue.Enqueue(10); - queue.Enqueue(20); - queue.Dequeue(); - } -} \ No newline at end of file diff --git a/LAB02/02/02.csproj b/LAB02/02/02.csproj deleted file mode 100644 index 1fdc33b..0000000 --- a/LAB02/02/02.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - _02 - enable - enable - - - diff --git a/LAB02/02/Program.cs b/LAB02/02/Program.cs deleted file mode 100644 index 6ae43fa..0000000 --- a/LAB02/02/Program.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Diagnostics; - -class EditDistance//Определяет класс EditDistance для вычисления редакционного расстояния между двумя строками. -{ - static int Min(int a, int b, int c)//Вспомогательный метод, возвращающий минимальное из трех заданных целых чисел. - { - return Math.Min(Math.Min(a, b), c); - } - - static int EditDistanceDP(string str1, string str2)//Статический метод, который вычисляет редакционное расстояние между двумя строками str1 и str2 с использованием динамического программирования.Содержит двумерный массив dp для хранения вычисленных значений. - { - int m = str1.Length; - int n = str2.Length; - - int[,] dp = new int[m + 1, n + 1];//Инициализирует массив dp базовыми случаями: dp[i, 0] = i: Если строка str1 пуста, расстояние равно длине str2.dp[0, j] = j: Если строка str2 пуста, расстояние равно длине str1. - - // Заполняем базовые случаи - for (int i = 0; i <= m; i++) - { - for (int j = 0; j <= n; j++) - { - if (i == 0) - dp[i, j] = j; // Если первая строка пустая, расстояние - длина второй строки - else if (j == 0) - dp[i, j] = i; // Если вторая строка пустая, расстояние - длина первой строки - else if (str1[i - 1] == str2[j - 1]) - dp[i, j] = dp[i - 1, j - 1]; // Если символы совпадают, берем значение из диагонали - else - dp[i, j] = 1 + Min(dp[i - 1, j], // Удаление - dp[i, j - 1], // Вставка - dp[i - 1, j - 1]); // Замена - } - } - - return dp[m, n]; - } - - static void Main(string[] args) - { - string str1 = "кот"; - string str2 = "скат"; - - // Измерение времени выполнения - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - int distance = EditDistanceDP(str1, str2); - stopwatch.Stop(); - Console.WriteLine("Редакционное расстояние между '{0}' и '{1}' равно {2}", str1, str2, distance); - Console.WriteLine("Время выполнения: " + stopwatch.ElapsedMilliseconds + " миллисекунд"); - - // Измерение использования памяти - Process currentProcess = Process.GetCurrentProcess(); - long memoryUsed = currentProcess.PrivateMemorySize64 / (1024 * 1024); // Переводим байты в мегабайты - - Console.WriteLine("Редакционное расстояние между '{0}' и '{1}' равно {2}", str1, str2, EditDistanceDP(str1, str2)); - } -} diff --git a/LAB02/03/03.csproj b/LAB02/03/03.csproj deleted file mode 100644 index 3386867..0000000 --- a/LAB02/03/03.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - _03 - enable - enable - - - diff --git a/LAB02/03/Program.cs b/LAB02/03/Program.cs deleted file mode 100644 index 5f28270..0000000 --- a/LAB02/03/Program.cs +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/LAB02/1/1.csproj b/LAB02/1/1.csproj deleted file mode 100644 index c828beb..0000000 --- a/LAB02/1/1.csproj +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Alg; - -class Program // O(n^2) -{ - static void Main(string[] args) - { - int n1 = Convert.ToInt32(Console.ReadLine()); - FindPrimes(n1); - } - - static void FindPrimes(int n) - { - bool[] isPrime = new bool[n + 1]; - for (int i = 2; i <= n; i++) - { - isPrime[i] = true; - } - - for (int i = 2; i <= n; i++) - { - - - if (isPrime[i] == true) - { - Console.Write(i + " "); - for (int j = i * i; j <= n; j += i) - { - isPrime[j] = false; - } - } - } - } -} diff --git a/LAB02/1/Program.cs b/LAB02/1/Program.cs deleted file mode 100644 index 3751555..0000000 --- a/LAB02/1/Program.cs +++ /dev/null @@ -1,2 +0,0 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); diff --git a/LAB02/2/2.csproj b/LAB02/2/2.csproj deleted file mode 100644 index 6ce99c6..0000000 --- a/LAB02/2/2.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - _2 - enable - enable - - - diff --git a/LAB02/2/Program.cs b/LAB02/2/Program.cs deleted file mode 100644 index 2272591..0000000 --- a/LAB02/2/Program.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Alg; -class Program // БЫСТРАЯ СОРТИРОВКА (В лучшем случае O(n*log(n)), в худшем O(n^2)) -{ - static void Main(string[] args) - { - int[] myArray = randomGenerate(10, 1, 100); // Создаем массив из 10000 элементов со значениями от 1 до 1000000 - - Console.WriteLine("Исходный массив:"); - printArray(myArray); // Выводим массив на экран - - quickSort(myArray, 0, myArray.Length - 1); // Сортируем массив быстрой сортировкой - Console.WriteLine("Отсортированный массив:"); - printArray(myArray); // Выводим отсортированный массив на экран - } - - static int[] randomGenerate(int size, int minValue, int maxValue) - { - Random rnd = new Random(); - int[] array = new int[size]; - for (int i = 0; i < size; i++) - { - array[i] = rnd.Next(minValue, maxValue + 1); // Генерируем случайное число от minValue до maxValue - } - return array; - } - - static void printArray(int[] array) - { - foreach (int num in array) - { - Console.Write(num + " "); - } - Console.WriteLine(); - } - - static void quickSort(int[] array, int low, int high) - { - if (low < high) - { - int pivotIndex = partition(array, low, high); - - // Рекурсивно сортируем элементы до и после опорного элемента - quickSort(array, low, pivotIndex - 1); - quickSort(array, pivotIndex + 1, high); - } - } - - static int partition(int[] array, int low, int high) - { - int pivot = array[high]; - int i = low - 1; // Индекс меньшего элемента - - for (int j = low; j < high; j++) - { - // Если текущий элемент меньше или равен опорному - if (array[j] <= pivot) - { - i++; - - // Обмен значениями - int temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - } - - // Обмен значениями - int temp1 = array[i + 1]; - array[i + 1] = array[high]; - array[high] = temp1; - - return i + 1; - } -} \ No newline at end of file diff --git a/LAB02/3.1/3.1.csproj b/LAB02/3.1/3.1.csproj deleted file mode 100644 index 68d5c48..0000000 --- a/LAB02/3.1/3.1.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - _3._1 - enable - enable - - - diff --git a/LAB02/3.1/Program.cs b/LAB02/3.1/Program.cs deleted file mode 100644 index 22ca218..0000000 --- a/LAB02/3.1/Program.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Alg; - -class Program // O(n^2)//Это объявление класса с именем "Program". Комментарий "// O(n^2)" указывает на то, что алгоритм внутри метода "FindPrimes" имеет временную сложность O(n^2), что означает квадратичную зависимость от размера входных данных. -{ - static void Main(string[] args)//Это объявление метода Main, который является точкой входа в программу. Он принимает массив строк args в качестве аргументов. - { - int n1 = Convert.ToInt32(Console.ReadLine());//Прочитывает ввод пользователя с консоли и конвертирует его в целое число, которое сохраняется в переменной n1. - FindPrimes(n1);//Вызов метода FindPrimes с аргументом n1. - } - - static void FindPrimes(int n)//Объявление метода FindPrimes, который принимает целочисленный аргумент n. - { - bool[] isPrime = new bool[n + 1];//Создание массива isPrime длиной n+1, который будет использоваться для отслеживания простых чисел. - for (int i = 2; i <= n; i++)//Начало цикла от 2 до n. - { - isPrime[i] = true;//Установка флага isPrimei в true, так как i является простым числом. - } - - for (int i = 2; i <= n; i++)//Начало второго цикла от 2 до n. - { - - - if (isPrime[i] == true)//Проверка, является ли число i простым. - { - Console.Write(i + " ");//Вывод числа i на консоль. - for (int j = i * i; j <= n; j += i)//Цикл, который помечает значения, кратные i, как непростые. - { - isPrime[j] = false;//Установка флага isPrimej в false, так как j не является простым числом. - } - } - } - } -} diff --git a/LAB02/3/3.csproj b/LAB02/3/3.csproj deleted file mode 100644 index b499880..0000000 --- a/LAB02/3/3.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Exe - net8.0 - _3 - enable - enable - - - diff --git a/LAB02/3/Program.cs b/LAB02/3/Program.cs deleted file mode 100644 index 27ec9af..0000000 --- a/LAB02/3/Program.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Alg; -class Program // O(log(n)) -{ - static void Main() - { - int[] arr = { 2, 3, 4, 10, 40 };//Инициализация массива arr с элементами 2, 3, 4, 10, 40. - int x = 10;//Определение переменной x, которая равна искомому элементу. - int result = BinarySearch(arr, x);//Вызов метода BinarySearch для поиска элемента x в массиве arr. - - if (result == -1)//Проверка результата поиска и вывод соответствующего сообщения. - - Console.WriteLine("Элемент не найден"); - else - Console.WriteLine("Элемент найден в индексе: " + result); - } - static int BinarySearch(int[] arr, int x)//Объявление метода BinarySearch, который принимает массив arr и искомый элемент x. - { - int left = 0;//Инициализация переменной left, которая указывает на начальный индекс массива. - int right = arr.Length - 1;//Инициализация переменной right, которая указывает на конечный индекс массива. - - while (left <= right)// Начало цикла, который выполняется, пока левая граница не превысит правую. - { - int mid = left + (right - left) / 2;//Вычисление среднего индекса mid для деления массива на две части. - - if (arr[mid] == x)//Проверка, является ли элемент в середине массива равным искомому элементу x. - return mid; - - if (arr[mid] < x)//Если элемент в середине меньше x, сдвигаем левую границу поиска. - left = mid + 1; - else - right = mid - 1;//Иначе сдвигаем правую границу поиска. - } - - return -1; // элемент не найден - } -} diff --git a/LAB02/LAB02.sln b/LAB02/LAB02.sln deleted file mode 100644 index 4fcc88b..0000000 --- a/LAB02/LAB02.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LAB02", "LAB02\LAB02.csproj", "{295B61E5-A2D5-453C-87D5-7CAC7ACABE3F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02", "02\02.csproj", "{CD634B3A-8F12-4936-9082-3EFD2EB0C4E7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03", "03", "{C21E56E7-6AC7-4310-963B-BDDC0AC3CBF6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2", "2\2.csproj", "{E69E6275-619D-4D71-B923-9963C88A9F2B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3", "3\3.csproj", "{3802D8BD-C1BC-4DCB-B205-2BC83722E194}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3.1", "3.1\3.1.csproj", "{42D05460-8C32-4F20-8606-07EA30B22E8C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {295B61E5-A2D5-453C-87D5-7CAC7ACABE3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {295B61E5-A2D5-453C-87D5-7CAC7ACABE3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {295B61E5-A2D5-453C-87D5-7CAC7ACABE3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {295B61E5-A2D5-453C-87D5-7CAC7ACABE3F}.Release|Any CPU.Build.0 = Release|Any CPU - {CD634B3A-8F12-4936-9082-3EFD2EB0C4E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CD634B3A-8F12-4936-9082-3EFD2EB0C4E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CD634B3A-8F12-4936-9082-3EFD2EB0C4E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CD634B3A-8F12-4936-9082-3EFD2EB0C4E7}.Release|Any CPU.Build.0 = Release|Any CPU - {E69E6275-619D-4D71-B923-9963C88A9F2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E69E6275-619D-4D71-B923-9963C88A9F2B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E69E6275-619D-4D71-B923-9963C88A9F2B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E69E6275-619D-4D71-B923-9963C88A9F2B}.Release|Any CPU.Build.0 = Release|Any CPU - {3802D8BD-C1BC-4DCB-B205-2BC83722E194}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3802D8BD-C1BC-4DCB-B205-2BC83722E194}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3802D8BD-C1BC-4DCB-B205-2BC83722E194}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3802D8BD-C1BC-4DCB-B205-2BC83722E194}.Release|Any CPU.Build.0 = Release|Any CPU - {42D05460-8C32-4F20-8606-07EA30B22E8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42D05460-8C32-4F20-8606-07EA30B22E8C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42D05460-8C32-4F20-8606-07EA30B22E8C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42D05460-8C32-4F20-8606-07EA30B22E8C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {E69E6275-619D-4D71-B923-9963C88A9F2B} = {C21E56E7-6AC7-4310-963B-BDDC0AC3CBF6} - {3802D8BD-C1BC-4DCB-B205-2BC83722E194} = {C21E56E7-6AC7-4310-963B-BDDC0AC3CBF6} - {42D05460-8C32-4F20-8606-07EA30B22E8C} = {C21E56E7-6AC7-4310-963B-BDDC0AC3CBF6} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4B6E121E-4A2B-40E0-B768-CFD795B324BA} - EndGlobalSection -EndGlobal diff --git a/LAB02/LAB02/LAB02.csproj b/LAB02/LAB02/LAB02.csproj deleted file mode 100644 index 2150e37..0000000 --- a/LAB02/LAB02/LAB02.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/LAB02/LAB02/Program.cs b/LAB02/LAB02/Program.cs deleted file mode 100644 index 8ed2e22..0000000 --- a/LAB02/LAB02/Program.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; - -class CoinChange -{ - static void MakeChange(int[] coins, int amount)// объявляет статический метод (без экземпляра класса) с именем MakeChange, который принимает два аргумента: coins - массив значений монет и amount - сумму, для которой нужно подобрать сдачу. - - { - Stopwatch stopwatch = new Stopwatch(); - stopwatch.Start(); - Array.Sort(coins);//сортирует массив монет в порядке возрастания. - Array.Reverse(coins);//переворачивает отсортированный массив, чтобы монеты были в порядке убывания. - - List change = new List();//создает новый пустой список для хранения монет, использованных для сдачи. - int totalCoins = 0; //инициализирует переменную totalCoins, которая будет хранить общее количество монет в сдаче, значением 0. - - - foreach (int coin in coins) // перебирает каждую монету в отсортированном массиве монет. - { - while (amount >= coin) //проверяет, является ли сумма больше или равна текущей монете. - { - change.Add(coin); //добавляет текущую монету в список сдачи. - amount -= coin;//вычитает значение текущей монеты из суммы. - - totalCoins++;//величивает счетчик общего количества монет на 1. - } - } - - Console.WriteLine("Монеты для сдачи:");//выводит строку "Монеты для сдачи:" в консоль. - foreach (int coin in change)//перебирает список сдачи - { - Console.Write(coin + " ");//выводит каждое значение монеты в консоль, разделяя их пробелами - } - Console.WriteLine("\nВсего монет: " + totalCoins);//выводит строку "Всего монет:" в консоль, а затем общее количество монет в сдаче - - - stopwatch.Stop(); - - Console.WriteLine($"\nВремя выполнения: {stopwatch.ElapsedMilliseconds} мс"); - - // Получаем данные о потреблении памяти - Process proc = Process.GetCurrentProcess(); - long memoryUsed = proc.PrivateMemorySize64; - - Console.WriteLine($"Использование памяти: {memoryUsed / 1024} KB"); - } - -static void Main(string[] args)//объявляет статический метод Main, который является входной точкой программы - { - int[] coins = { 25, 10, 5, 1 };//создает массив монет с номиналами 25, 10, 5 и 1. - int amount = 63;//устанавливает сумму для сдачи в 63 единицы. - - MakeChange(coins, amount);//вызывает метод MakeChange, передавая ему массив монет и сумму. - } -} diff --git a/WinFormsApp1/WinFormsApp1.sln b/WinFormsApp1/WinFormsApp1.sln deleted file mode 100644 index cc16879..0000000 --- a/WinFormsApp1/WinFormsApp1.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsApp1", "WinFormsApp1\WinFormsApp1.csproj", "{50092433-6AF5-4E71-9559-079AE2F9901A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {50092433-6AF5-4E71-9559-079AE2F9901A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {50092433-6AF5-4E71-9559-079AE2F9901A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {50092433-6AF5-4E71-9559-079AE2F9901A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {50092433-6AF5-4E71-9559-079AE2F9901A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {59C3FED6-0E53-4AF0-9E1B-5ACF902ED5CE} - EndGlobalSection -EndGlobal diff --git a/WinFormsApp1/WinFormsApp1/Form1.Designer.cs b/WinFormsApp1/WinFormsApp1/Form1.Designer.cs deleted file mode 100644 index 1ac166c..0000000 --- a/WinFormsApp1/WinFormsApp1/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace WinFormsApp1 -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/WinFormsApp1/WinFormsApp1/Form1.cs b/WinFormsApp1/WinFormsApp1/Form1.cs deleted file mode 100644 index dabe0d0..0000000 --- a/WinFormsApp1/WinFormsApp1/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace WinFormsApp1 -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/WinFormsApp1/WinFormsApp1/Form1.resx b/WinFormsApp1/WinFormsApp1/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/WinFormsApp1/WinFormsApp1/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/WinFormsApp1/WinFormsApp1/Program.cs b/WinFormsApp1/WinFormsApp1/Program.cs deleted file mode 100644 index 1e39c2a..0000000 --- a/WinFormsApp1/WinFormsApp1/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace WinFormsApp1 -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); - } - } -} \ No newline at end of file diff --git a/WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj b/WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj deleted file mode 100644 index 663fdb8..0000000 --- a/WinFormsApp1/WinFormsApp1/WinFormsApp1.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net8.0-windows - enable - true - enable - - - \ No newline at end of file