From f24c97cfb59c0bb57d656e8ca6ef54a7ea93f774 Mon Sep 17 00:00:00 2001 From: Stanislav Mykhailenko Date: Tue, 11 Apr 2023 23:29:05 +0300 Subject: [PATCH] Update Lesson 4 Task 2 --- Lesson_4/Task_2/Classes/FireMagic.cs | 2 +- Lesson_4/Task_2/Classes/Magic.cs | 6 +++--- Lesson_4/Task_2/Classes/WaterMagic.cs | 2 +- Lesson_4/Task_2/Interfaces/IMagic.cs | 3 +-- Lesson_4/Task_2/Interfaces/IMagicClass.cs | 14 ++++++++++++++ Lesson_4/Task_2/Task_2.csproj | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 Lesson_4/Task_2/Interfaces/IMagicClass.cs diff --git a/Lesson_4/Task_2/Classes/FireMagic.cs b/Lesson_4/Task_2/Classes/FireMagic.cs index 6b5de4a..8842b59 100644 --- a/Lesson_4/Task_2/Classes/FireMagic.cs +++ b/Lesson_4/Task_2/Classes/FireMagic.cs @@ -8,7 +8,7 @@ using Open_Closed.Interfaces; namespace Open_Closed.Classes { - public class FireMagic : IMagic + public class FireMagic : IMagicClass { public int MagicValue { get { return 150; } } public string MagicType { get { return "fire"; } } diff --git a/Lesson_4/Task_2/Classes/Magic.cs b/Lesson_4/Task_2/Classes/Magic.cs index c8357a5..0024c62 100644 --- a/Lesson_4/Task_2/Classes/Magic.cs +++ b/Lesson_4/Task_2/Classes/Magic.cs @@ -8,11 +8,11 @@ using Open_Closed.Interfaces; namespace Open_Closed.Classes { - public class Magic + public class Magic : IMagic { - public void CountYourMagic(IMagic Magic) + public void CountYourMagic(IMagicClass MagicClass) { - Console.WriteLine($"Your magic is {Magic.MagicType}."); + Console.WriteLine($"Your magic is {MagicClass.MagicType}."); } } } diff --git a/Lesson_4/Task_2/Classes/WaterMagic.cs b/Lesson_4/Task_2/Classes/WaterMagic.cs index ef45f6f..aef7e32 100644 --- a/Lesson_4/Task_2/Classes/WaterMagic.cs +++ b/Lesson_4/Task_2/Classes/WaterMagic.cs @@ -8,7 +8,7 @@ using Open_Closed.Interfaces; namespace Open_Closed.Classes { - public class WaterMagic : IMagic + public class WaterMagic : IMagicClass { public int MagicValue { get { return 50000000; } } public string MagicType { get { return "water"; } } diff --git a/Lesson_4/Task_2/Interfaces/IMagic.cs b/Lesson_4/Task_2/Interfaces/IMagic.cs index 1a2d623..417e11d 100644 --- a/Lesson_4/Task_2/Interfaces/IMagic.cs +++ b/Lesson_4/Task_2/Interfaces/IMagic.cs @@ -8,7 +8,6 @@ namespace Open_Closed.Interfaces { public interface IMagic { - int MagicValue { get; } - string MagicType { get; } + void CountYourMagic(IMagicClass MagicClass); } } diff --git a/Lesson_4/Task_2/Interfaces/IMagicClass.cs b/Lesson_4/Task_2/Interfaces/IMagicClass.cs new file mode 100644 index 0000000..7a44e78 --- /dev/null +++ b/Lesson_4/Task_2/Interfaces/IMagicClass.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Open_Closed.Interfaces +{ + public interface IMagicClass + { + int MagicValue { get; } + string MagicType { get; } + } +} diff --git a/Lesson_4/Task_2/Task_2.csproj b/Lesson_4/Task_2/Task_2.csproj index f02677b..74abf5c 100644 --- a/Lesson_4/Task_2/Task_2.csproj +++ b/Lesson_4/Task_2/Task_2.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net6.0 enable enable