hkujyhtgfd

This commit is contained in:
elizaveta 2024-10-08 12:32:16 +04:00
parent 43ba6f6d5f
commit 158ee34849
17 changed files with 387 additions and 240 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project_Teoria_sozdania", "Project_Teoria_sozdania\Project_Teoria_sozdania.csproj", "{8F0E264D-2AD1-4B46-BDCD-2EDDCF1FD0D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8F0E264D-2AD1-4B46-BDCD-2EDDCF1FD0D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F0E264D-2AD1-4B46-BDCD-2EDDCF1FD0D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F0E264D-2AD1-4B46-BDCD-2EDDCF1FD0D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F0E264D-2AD1-4B46-BDCD-2EDDCF1FD0D9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {18192B79-F78E-451E-B244-BCAF80B6C223}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,9 @@
<Application x:Class="Project_Teoria_sozdania.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Project_Teoria_sozdania"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Project_Teoria_sozdania
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,12 @@
<Window x:Class="Project_Teoria_sozdania.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Project_Teoria_sozdania"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Project_Teoria_sozdania
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>

View File

@ -1,5 +1,5 @@
using Tank.Drowings; using Tank.Drowings;
namespace Tank.CollectionGenericObjects; using Tank.CollectionGenericObjects;
/// <summary> /// <summary>
/// Абстракция компании, хранящий коллекцию автомобилей /// Абстракция компании, хранящий коллекцию автомобилей
@ -9,12 +9,12 @@ public abstract class AbstractCompany
/// <summary> /// <summary>
/// Размер места (ширина) /// Размер места (ширина)
/// </summary> /// </summary>
protected readonly int _placeSizeWidth = 250; protected readonly int _placeSizeWidth = 295;
/// <summary> /// <summary>
/// Размер места (высота) /// Размер места (высота)
/// </summary> /// </summary>
protected readonly int _placeSizeHeight = 150; protected readonly int _placeSizeHeight = 160;
/// <summary> /// <summary>
/// Ширина окна /// Ширина окна
@ -67,9 +67,9 @@ public abstract class AbstractCompany
/// <param name="company">Компания</param> /// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param> /// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns> /// <returns></returns>
public static DrawningMachine operator -(AbstractCompany company, int position) public static DrawningMachine? operator -(AbstractCompany company, int position)
{ {
return company._collection?.Remove(position); return company._collection?.Remove(position) ?? null;
} }
/// <summary> /// <summary>

View File

@ -14,15 +14,16 @@ where T : class
/// Количество объектов в коллекции /// Количество объектов в коллекции
/// </summary> /// </summary>
int Count { get; } int Count { get; }
/// <summary> ///<summary>
/// Установка максимального количества элементов /// Установка макс. кол-ва элементов
/// </summary>
int MaxCount { get; set; } int MaxCount { get; set; }
///</summary>
/// <summary> /// <summary>
/// Добавление объекта в коллекцию /// Добавление объекта в коллекцию
/// </summary> /// </summary>
/// <param name="obj">Добавляемый объект</param> /// <param name="obj">Добавляемый объект</param>
/// <returns>другое число - вставка прошла удачно, -1 - вставка не удалась</returns> /// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj); int Insert(T obj);
/// <summary> /// <summary>
/// Добавление объекта в коллекцию на конкретную позицию /// Добавление объекта в коллекцию на конкретную позицию

View File

@ -7,24 +7,39 @@ using Tank.Exceptions;
namespace Tank.CollectionGenericObjects; namespace Tank.CollectionGenericObjects;
public class ListGenericObjects<T> : ICollectionGenericObjects<T> where T : class /// <summary>
/// Параметризованный набор объектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{ {
/// <summary>
/// Список объектов, которые храним
/// </summary>
private readonly List<T?> _collection; private readonly List<T?> _collection;
/// <summary>
/// Максимально допустимое число объектов в списке
/// </summary>
private int _maxCount; private int _maxCount;
public int Count => _collection.Count; public int Count => _collection.Count;
public CollectionType GetCollectionType => CollectionType.List;
public int MaxCount public int MaxCount
{ {
get get
{ {
return _maxCount; return _collection.Count;
} }
set set
{ {
if (value > 0) _maxCount = value; if (value > 0)
{
_maxCount = value - 1;
} }
} }
}
public CollectionType GetCollectionType => CollectionType.List;
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -36,31 +51,51 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T> where T : clas
public T? Get(int position) public T? Get(int position)
{ {
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); //TODO проверка позиции
if (position >= Count || position < 0)
{
throw new PositionOutOfCollectionException(position);
}
return _collection[position]; return _collection[position];
} }
public int Insert(T obj) public int Insert(T obj)
{ {
if (Count == _maxCount) throw new CollectionOverflowException(Count); // TODO проверка, что не превышено максимальное количество элементов
if (Count == _maxCount)
{
throw new CollectionOverflowException(Count);
}
//TODO вставка в конец набора
_collection.Add(obj); _collection.Add(obj);
return Count; return _collection.Count;
} }
public int Insert(T obj, int position) public int Insert(T obj, int position)
{ {
if (position < 0 || position >= Count) //TODO проверка что не превышено максимальное кол-во элементов
throw new PositionOutOfCollectionException(position);
if (Count == _maxCount) if (Count == _maxCount)
{
throw new CollectionOverflowException(Count); throw new CollectionOverflowException(Count);
}
// TODO проверка позиции
if (position >= Count || position < 0)
{
throw new PositionOutOfCollectionException(position);
}
// TODO вставка по позиции
_collection.Insert(position, obj); _collection.Insert(position, obj);
return position; return position;
} }
public T? Remove(int position) public T? Remove(int position)
{ {
if (position >= Count || position < 0) throw new PositionOutOfCollectionException(position); // TODO проверка позиции
if (position >= Count || position < 0)
{
throw new PositionOutOfCollectionException(position);
}
// TODO удаление объекта из списка
T? obj = _collection[position]; T? obj = _collection[position];
_collection.RemoveAt(position); _collection.RemoveAt(position);
return obj; return obj;
@ -68,7 +103,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T> where T : clas
public IEnumerable<T?> GetItems() public IEnumerable<T?> GetItems()
{ {
for (int i = 0; i < _collection.Count; i++) for (int i = 0; i < _collection.Count; ++i)
{ {
yield return _collection[i]; yield return _collection[i];
} }

View File

@ -10,6 +10,9 @@ namespace Tank.CollectionGenericObjects;
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T> public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class where T : class
{ {
/// <summary>
/// Массив объектов, которые храним
/// </summary>
private T?[] _collection; private T?[] _collection;
public int Count => _collection.Length; public int Count => _collection.Length;
public int MaxCount public int MaxCount
@ -24,11 +27,11 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
{ {
if (_collection.Length > 0) if (_collection.Length > 0)
{ {
Array.Resize(ref _collection, value - 9); Array.Resize(ref _collection, value);
} }
else else
{ {
_collection = new T?[value - 9]; _collection = new T?[value - 1];
} }
} }
} }
@ -46,33 +49,26 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
public T Get(int position) public T Get(int position)
{ {
if (position < 0 || position >= _collection.Length) if (position < 0 || position > _collection.Length)
{ {
throw new PositionOutOfCollectionException(); throw new PositionOutOfCollectionException(position);
} }
if (_collection[position] == null) if (position >= Count && _collection[position] == null)
{ {
throw new ObjectNotFoundException(position); ////////////// throw new ObjectNotFoundException(position); /////////////////////////////////////////////////////////////
} }
return _collection[position]; return _collection[position];
} }
public int Insert(T obj) public int Insert(T obj)
{ {
for (int i = 0; i < _collection.Length; i++) return Insert(obj, 0);
{
if (_collection[i] == null)
{
_collection[i] = obj;
return i;
}
}
throw new CollectionOverflowException(Count); throw new CollectionOverflowException(Count);
} }
public int Insert(T obj, int position) public int Insert(T obj, int position)
{ {
if (position < 0 || position >= _collection.Length) if (position > _collection.Length || position < 0)
{ {
throw new PositionOutOfCollectionException(position); throw new PositionOutOfCollectionException(position);
} }
@ -82,42 +78,44 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
_collection[position] = obj; _collection[position] = obj;
return position; return position;
} }
else
for (int tmp = position + 1; tmp < _collection.Length; tmp++)
{ {
for (int i = position; i < _collection.Length; ++i) //ищем свободное место справа if (_collection[tmp] == null)
{ {
if (_collection[i] == null) _collection[tmp] = obj;
{ return tmp;
_collection[i] = obj;
return i;
} }
} }
for (int i = 0; i < position; ++i) // иначе слева
for (int tmp = position - 1; tmp >= 0; tmp--)
{ {
if (_collection[i] == null) if (_collection[tmp] == null)
{ {
_collection[i] = obj; _collection[tmp] = obj;
return i; return tmp;
}
} }
} }
throw new CollectionOverflowException(Count); throw new CollectionOverflowException(Count);
} }
public T? Remove(int position) public T? Remove(int position)
{ {
if (position < 0 || position >= _collection.Length) // TODO проверка позиции
if (position < 0 || position > _collection.Length)
{
throw new PositionOutOfCollectionException(position); throw new PositionOutOfCollectionException(position);
T? obj = _collection[position]; }
if (_collection[position] == null) if (_collection[position] == null)
{ {
throw new ObjectNotFoundException(position); throw new ObjectNotFoundException(position);
} }
if (_collection[position] != null) T? tmp = _collection[position];
{
_collection[position] = null; _collection[position] = null;
} // TODO удаление объекта из массива, присвоив элементу массива значение null
return obj; return tmp;
} }
public IEnumerable<T?> GetItems() public IEnumerable<T?> GetItems()

View File

@ -12,7 +12,7 @@ namespace Tank.CollectionGenericObjects;
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class StorageCollection<T> public class StorageCollection<T>
where T : DrawningMachine where T : DrawningMachine
{ {
/// <summary> /// <summary>
/// Словарь (хранилище) с коллекциями /// Словарь (хранилище) с коллекциями
/// </summary> /// </summary>
@ -23,6 +23,21 @@ public class StorageCollection<T>
/// </summary> /// </summary>
public List<string> Keys => _storages.Keys.ToList(); public List<string> Keys => _storages.Keys.ToList();
/// <summary>
/// Ключевое слово, с которого должен начинаться файл
/// </summary>
private readonly string _collectionKey = "CollectionStorage";
/// <summary>
/// Разделитель для записи ключа и значения элемента словаря
/// </summary>
private readonly string _separatorForKeyValue = "|";
/// <summary>
/// Разделитель для записей коллекции данных в файл
/// </summary>
private readonly string _separatorItems = ";";
/// <summary> /// <summary>
/// Конструктор /// Конструктор
/// </summary> /// </summary>
@ -30,7 +45,6 @@ public class StorageCollection<T>
{ {
_storages = new Dictionary<string, ICollectionGenericObjects<T>>(); _storages = new Dictionary<string, ICollectionGenericObjects<T>>();
} }
/// <summary> /// <summary>
/// Добавление коллекции в хранилище /// Добавление коллекции в хранилище
/// </summary> /// </summary>
@ -38,19 +52,19 @@ public class StorageCollection<T>
/// <param name="collectionType">тип коллекции</param> /// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType) public void AddCollection(string name, CollectionType collectionType)
{ {
if (string.IsNullOrEmpty(name) || _storages.ContainsKey(name)) // TODO проверка, что name не пустой и нет в словаре записи с таким ключом
{ // TODO Прописать логику для добавления
if (name == null || _storages.ContainsKey(name))
return; return;
}
switch (collectionType) switch (collectionType)
{ {
case CollectionType.None:
return;
case CollectionType.Massive: case CollectionType.Massive:
_storages[name] = new MassiveGenericObjects<T>(); _storages[name] = new MassiveGenericObjects<T>();
break; return;
case CollectionType.List: case CollectionType.List:
_storages[name] = new ListGenericObjects<T>(); _storages[name] = new ListGenericObjects<T>();
break;
default:
return; return;
} }
} }
@ -61,13 +75,11 @@ public class StorageCollection<T>
/// <param name="name">Название коллекции</param> /// <param name="name">Название коллекции</param>
public void DelCollection(string name) public void DelCollection(string name)
{ {
// TODO Прописать логику для удаления коллекции
if (_storages.ContainsKey(name)) if (_storages.ContainsKey(name))
{
_storages.Remove(name); _storages.Remove(name);
} }
}
/// <summary> /// <summary>
/// Доступ к коллекции /// Доступ к коллекции
/// </summary> /// </summary>
@ -77,25 +89,13 @@ public class StorageCollection<T>
{ {
get get
{ {
if (_storages.ContainsKey(name)) // TODO Продумать логику получения объекта
{ if (name == null || !_storages.ContainsKey(name))
return null;
return _storages[name]; return _storages[name];
} }
return null;
} }
}
/// <summary>
/// Ключевое слово, с которого должен начинаться файл
/// </summary>
private readonly string _collectionKey = "CollectionsStorage";
/// <summary>
/// Разделитель для записи ключа и значения элемента словаря
/// </summary>
private readonly string _separatorForKeyValue = "|";
/// <summary>
/// Разделитель для записей коллекции данных в файл
/// </summary>
private readonly string _separatorItems = ";";
/// <summary> /// <summary>
/// Сохранение информации по самолетам в хранилище в файл /// Сохранение информации по самолетам в хранилище в файл
/// </summary> /// </summary>
@ -105,28 +105,30 @@ public class StorageCollection<T>
{ {
if (_storages.Count == 0) if (_storages.Count == 0)
{ {
throw new Exception("В хранилище отсутствуют коллекции для сохранения"); throw new InvalidDataException("В хранилище отсутствуют коллекции для сохранения");
} }
if (File.Exists(filename)) if (File.Exists(filename))
{ {
File.Delete(filename); File.Delete(filename);
} }
StringBuilder sb = new(); using FileStream fs = new(filename, FileMode.Create);
sb.Append(_collectionKey); using StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(_collectionKey);
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages) foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
{ {
sb.Append(Environment.NewLine); sw.Write(Environment.NewLine);
// не сохраняем пустые коллекции // не сохраняем пустые коллекции
if (value.Value.Count == 0) if (value.Value.Count == 0)
{ {
continue; continue;
} }
sb.Append(value.Key); sw.Write(value.Key);
sb.Append(_separatorForKeyValue); sw.Write(_separatorForKeyValue);
sb.Append(value.Value.GetCollectionType); sw.Write(value.Value.GetCollectionType);
sb.Append(_separatorForKeyValue); sw.Write(_separatorForKeyValue);
sb.Append(value.Value.MaxCount); sw.Write(value.Value.MaxCount);
sb.Append(_separatorForKeyValue); sw.Write(_separatorForKeyValue);
foreach (T? item in value.Value.GetItems()) foreach (T? item in value.Value.GetItems())
{ {
string data = item?.GetDataForSave() ?? string.Empty; string data = item?.GetDataForSave() ?? string.Empty;
@ -134,15 +136,12 @@ public class StorageCollection<T>
{ {
continue; continue;
} }
sb.Append(data);
sb.Append(_separatorItems);
}
}
using FileStream fs = new(filename, FileMode.Create);
byte[] info = new UTF8Encoding(true).GetBytes(sb.ToString());
fs.Write(info, 0, info.Length);
}
sw.Write(data);
sw.Write(_separatorItems);
}
}
}
/// <summary> /// <summary>
/// Загрузка информации по самолетам в хранилище из файла /// Загрузка информации по самолетам в хранилище из файла
@ -153,49 +152,56 @@ public class StorageCollection<T>
{ {
if (!File.Exists(filename)) if (!File.Exists(filename))
{ {
throw new Exception("Файл не существует"); throw new FileNotFoundException("Файл не существует");
} }
using (StreamReader sr = new StreamReader(filename)) using (StreamReader reader = new(filename))
{ {
string? str; string line = reader.ReadLine();
str = sr.ReadLine(); if (line == null || line.Length == 0)
if (str == null || str.Length == 0) {
throw new Exception("В файле нет данных"); throw new InvalidDataException("В файле нет данных");
if (str != _collectionKey.ToString()) }
throw new Exception("В файле неверные данные"); if (!line.Equals(_collectionKey))
{
throw new InvalidOperationException("В файле неверные данные");
}
_storages.Clear(); _storages.Clear();
while ((str = sr.ReadLine()) != null) while ((line = reader.ReadLine()) != null)
{ {
string[] record = str.Split(_separatorForKeyValue); string[] record = line.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
if (record.Length != 4) if (record.Length != 4)
{ {
continue; continue;
} }
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]); CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType); ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
if (collection == null) if (collection == null)
{ {
throw new Exception("Не удалось создать коллекцию"); throw new InvalidOperationException("Не удалось создать коллекцию");
} }
collection.MaxCount = Convert.ToInt32(record[2]) + 9; collection.MaxCount = Convert.ToInt32(record[2]);
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries); string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
foreach (string elem in set) foreach (string elem in set)
{ {
if (elem?.CreateDrawningMachine() is T machine) if (elem?.CreateDrawningMachine() is T locomotive)
{ {
try try
{ {
if (collection.Insert(machine) == -1) if (collection.Insert(locomotive) == -1)
throw new Exception("Объект не удалось добавить в коллекцию: " + record[3]); {
throw new InvalidOperationException("Объект не удалось добавить в коллекцию: " + record[3]);
}
} }
catch (CollectionOverflowException ex) catch (CollectionOverflowException ex)
{ {
throw new Exception("Коллекция переполнена", ex); throw new ArgumentOutOfRangeException("Коллекция переполнена", ex);
} }
} }
} }
_storages.Add(record[0], collection); _storages.Add(record[0], collection);
} }
@ -207,14 +213,13 @@ public class StorageCollection<T>
/// </summary> /// </summary>
/// <param name="collectionType"></param> /// <param name="collectionType"></param>
/// <returns></returns> /// <returns></returns>
private static ICollectionGenericObjects<T>? private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
CreateCollection(CollectionType collectionType)
{ {
return collectionType switch return collectionType switch
{ {
CollectionType.Massive => new MassiveGenericObjects<T>(), CollectionType.Massive => new MassiveGenericObjects<T>(),
CollectionType.List => new ListGenericObjects<T>(), CollectionType.List => new ListGenericObjects<T>(),
_ => null, _ => null
}; };
} }
} }

View File

@ -10,18 +10,16 @@ public class TankSharingService : AbstractCompany
protected override void DrawBackgound(Graphics g) protected override void DrawBackgound(Graphics g)
{ {
Pen pen = new(Color.Black, 3); int width = _pictureWidth / _placeSizeWidth;
int posX = 0; int height = _pictureHeight / _placeSizeHeight;
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) Pen pen = new(Color.Black, 7);
for (int i = 0; i < width + 1; i++)
{ {
int posY = 0; for (int j = 0; j < height + 1; ++j)
g.DrawLine(pen, posX, posY, posX, posY + _placeSizeHeight * (_pictureHeight / _placeSizeHeight));
for (int j = 0; j <= _pictureHeight / _placeSizeHeight; j++)
{ {
g.DrawLine(pen, posX, posY, posX + _placeSizeWidth - 30, posY); g.DrawLine(pen, i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + 5 + _placeSizeWidth - 45, j * _placeSizeHeight);
posY += _placeSizeHeight; g.DrawLine(pen, i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + 5, j * _placeSizeHeight - _placeSizeHeight);
} }
posX += _placeSizeWidth;
} }
} }
@ -36,7 +34,7 @@ public class TankSharingService : AbstractCompany
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
_collection?.Get(i)?.SetPosition(posX * _placeSizeWidth + 5, posY * _placeSizeHeight + 5); _collection?.Get(i)?.SetPosition(posX * _placeSizeWidth + 5, posY * _placeSizeHeight + 5);
} }
if (posX < _pictureWidth/_placeSizeWidth - 1) if (posX < _pictureWidth / _placeSizeWidth - 1)
{ {
posX++; posX++;
} }
@ -45,7 +43,7 @@ public class TankSharingService : AbstractCompany
posY++; posY++;
posX = 0; posX = 0;
} }
if (posY > _pictureHeight/_placeSizeHeight) { return; } if (posY > _pictureHeight / _placeSizeHeight) { return; }
} }
} }
} }

View File

@ -11,7 +11,7 @@ namespace Tank.Exceptions;
/// Класс, описывающий ошибку переполнения коллекции /// Класс, описывающий ошибку переполнения коллекции
/// </summary> /// </summary>
[Serializable] [Serializable]
public class CollectionOverflowException : ApplicationException internal class CollectionOverflowException : ApplicationException
{ {
public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { } public CollectionOverflowException(int count) : base("В коллекции превышено допустимое количество: " + count) { }
public CollectionOverflowException() : base() { } public CollectionOverflowException() : base() { }

View File

@ -11,9 +11,9 @@ namespace Tank.Exceptions;
/// Класс, описывающий ошибку, что по указанной позиции нет элемента /// Класс, описывающий ошибку, что по указанной позиции нет элемента
/// </summary> /// </summary>
[Serializable] [Serializable]
public class ObjectNotFoundException : ApplicationException internal class ObjectNotFoundException : ApplicationException
{ {
public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i){ } public ObjectNotFoundException(int i) : base("Не найден объект по позиции " + i) { }
public ObjectNotFoundException() : base() { } public ObjectNotFoundException() : base() { }
public ObjectNotFoundException(string message) : base(message) { } public ObjectNotFoundException(string message) : base(message) { }
public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { } public ObjectNotFoundException(string message, Exception exception) : base(message, exception) { }

View File

@ -66,7 +66,7 @@
groupBoxTools.Controls.Add(panelStorage); groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany); groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right; groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(1174, 40); groupBoxTools.Location = new Point(1182, 40);
groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(371, 990); groupBoxTools.Size = new Size(371, 990);
groupBoxTools.TabIndex = 0; groupBoxTools.TabIndex = 0;
@ -86,7 +86,6 @@
panelCompanyTools.Name = "panelCompanyTools"; panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(365, 310); panelCompanyTools.Size = new Size(365, 310);
panelCompanyTools.TabIndex = 9; panelCompanyTools.TabIndex = 9;
// //
// buttonAddTank // buttonAddTank
// //
@ -250,7 +249,7 @@
pictureBox.Dock = DockStyle.Fill; pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 40); pictureBox.Location = new Point(0, 40);
pictureBox.Name = "pictureBox"; pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(1174, 990); pictureBox.Size = new Size(1182, 990);
pictureBox.TabIndex = 1; pictureBox.TabIndex = 1;
pictureBox.TabStop = false; pictureBox.TabStop = false;
// //
@ -260,7 +259,7 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
menuStrip1.Location = new Point(0, 0); menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1"; menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(1545, 40); menuStrip1.Size = new Size(1553, 40);
menuStrip1.TabIndex = 2; menuStrip1.TabIndex = 2;
menuStrip1.Text = "menuStrip1"; menuStrip1.Text = "menuStrip1";
// //
@ -299,7 +298,7 @@
// //
AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1545, 1030); ClientSize = new Size(1553, 1030);
Controls.Add(pictureBox); Controls.Add(pictureBox);
Controls.Add(groupBoxTools); Controls.Add(groupBoxTools);
Controls.Add(menuStrip1); Controls.Add(menuStrip1);