From d83fc2dc2b8dfc8e62f166d67d24673d7efa7fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Thu, 1 Dec 2022 23:49:16 +0400 Subject: [PATCH] Fix fix 2 --- GasolineTanker/GasolineTanker/Program.cs | 2 +- .../GasolineTanker/SetGasolineTankerGeneric.cs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/GasolineTanker/GasolineTanker/Program.cs b/GasolineTanker/GasolineTanker/Program.cs index 8a03804..46291d9 100644 --- a/GasolineTanker/GasolineTanker/Program.cs +++ b/GasolineTanker/GasolineTanker/Program.cs @@ -30,7 +30,7 @@ namespace GasolineTanker { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile(path: "C:\\Users\\kashi\\Desktop\\RPP\\GasolineTankerBase\\Base\\GasolineTanker\\GasolineTanker\\appSetting.json", optional: false, reloadOnChange: true) + .AddJsonFile(path: "C:\\Users\\kashi\\Desktop\\RPP\\GasolineTanker\\GasolineTanker\\GasolineTanker\\appSetting.json", optional: false, reloadOnChange: true) .Build(); var logger = new LoggerConfiguration() diff --git a/GasolineTanker/GasolineTanker/SetGasolineTankerGeneric.cs b/GasolineTanker/GasolineTanker/SetGasolineTankerGeneric.cs index c782a6a..0063d66 100644 --- a/GasolineTanker/GasolineTanker/SetGasolineTankerGeneric.cs +++ b/GasolineTanker/GasolineTanker/SetGasolineTankerGeneric.cs @@ -27,15 +27,17 @@ namespace GasolineTanker } public int Insert(T gasolineTanker, int position) { - if (_places.Contains(gasolineTanker)) - throw new ArgumentException($"The {gasolineTanker} object is already in the set"); if (Count == _maxCount) throw new StorageOverflowException(_maxCount); - if (!isCorrectPosition(position)) - { + + if (position < 0 || position > Count) return -1; - } + + if (_places.Contains(gasolineTanker)) + return -1; + _places.Insert(position, gasolineTanker); + return position; } public T Remove(int position)