From 47cf7a6743095502a969fc664014e3e6e5b8aa37 Mon Sep 17 00:00:00 2001 From: Kirill <117719052+KirillFirsof@users.noreply.github.com> Date: Mon, 25 Dec 2023 22:08:53 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarNotFoundException.cs | 24 +++++++++++++++++++ .../StorageOverflowException.cs | 23 ++++++++++++++++++ .../TractorsGenericStorage.cs | 6 ++--- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs create mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs new file mode 100644 index 0000000..19b8d4a --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.Serialization; + + +namespace ProjectTractor.Exceptions +{ + [Serializable] + internal class CarNotFoundException : ApplicationException + { + public CarNotFoundException(int i) : base($"Не найден объект по позиции { i}") { } + public CarNotFoundException() : base() { } + public CarNotFoundException(string message) : base(message) { } + public CarNotFoundException(string message, Exception exception) : + base(message, exception) + { } + protected CarNotFoundException(SerializationInfo info, + StreamingContext contex) : base(info, contex) { } + } + +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs new file mode 100644 index 0000000..81d05e7 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Runtime.Serialization; + + +namespace ProjectTractor.Exceptions +{ + [Serializable] + internal class StorageOverflowException : ApplicationException + { + public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: { count}") { } + public StorageOverflowException() : base() { } + public StorageOverflowException(string message) : base(message) { } + public StorageOverflowException(string message, Exception exception) + : base(message, exception) { } + protected StorageOverflowException(SerializationInfo info, + StreamingContext contex) : base(info, contex) { } + } + +} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs index 00378ca..d71695f 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs @@ -158,10 +158,10 @@ namespace ProjectTractor string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); foreach (string elem in set) { - DrawningTractor? bus = elem?.CreateDrawningTractor(_separatorForObject, _pictureWidth, _pictureHeight); - if (bus != null) + DrawningTractor? tractor = elem?.CreateDrawningTractor(_separatorForObject, _pictureWidth, _pictureHeight); + if (tractor != null) { - if (!(collection + bus)) + if (!(collection + tractor)) { return false; }