diff --git a/Lesson_4/Task_2/FireMagic.cs b/Lesson_4/Task_2/Classes/FireMagic.cs similarity index 62% rename from Lesson_4/Task_2/FireMagic.cs rename to Lesson_4/Task_2/Classes/FireMagic.cs index 407f147..3026a2c 100644 --- a/Lesson_4/Task_2/FireMagic.cs +++ b/Lesson_4/Task_2/Classes/FireMagic.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Open_Closed +using Open_Closed.Interfaces; + +namespace Open_Closed.Classes { - public class FireMagic : Magic + public class FireMagic : IMagic { - public override void CountYourMagic() + public void CountYourMagic() { Console.WriteLine("Wow, your magic is fire magic!"); } diff --git a/Lesson_4/Task_2/Magic.cs b/Lesson_4/Task_2/Classes/UnknownMagic.cs similarity index 60% rename from Lesson_4/Task_2/Magic.cs rename to Lesson_4/Task_2/Classes/UnknownMagic.cs index 5b4d30c..f94bf1a 100644 --- a/Lesson_4/Task_2/Magic.cs +++ b/Lesson_4/Task_2/Classes/UnknownMagic.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Open_Closed +using Open_Closed.Interfaces; + +namespace Open_Closed.Classes { - public class Magic + public class UnknownMagic : IMagic { - public virtual void CountYourMagic() + public void CountYourMagic() { Console.WriteLine("I understand you..."); } diff --git a/Lesson_4/Task_2/WaterMagic.cs b/Lesson_4/Task_2/Classes/WaterMagic.cs similarity index 64% rename from Lesson_4/Task_2/WaterMagic.cs rename to Lesson_4/Task_2/Classes/WaterMagic.cs index 036d157..e37694a 100644 --- a/Lesson_4/Task_2/WaterMagic.cs +++ b/Lesson_4/Task_2/Classes/WaterMagic.cs @@ -4,11 +4,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Open_Closed +using Open_Closed.Interfaces; + +namespace Open_Closed.Classes { - public class WaterMagic : Magic + public class WaterMagic : IMagic { - public override void CountYourMagic() + public void CountYourMagic() { Console.WriteLine("Incredible! You have 50 millions of power! It's water magic!"); } diff --git a/Lesson_4/Task_2/Interfaces/IMagic.cs b/Lesson_4/Task_2/Interfaces/IMagic.cs new file mode 100644 index 0000000..6474543 --- /dev/null +++ b/Lesson_4/Task_2/Interfaces/IMagic.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Open_Closed.Interfaces +{ + public interface IMagic + { + void CountYourMagic(); + } +} diff --git a/Lesson_4/Task_2/Program.cs b/Lesson_4/Task_2/Program.cs index 3751555..5cd1c52 100644 --- a/Lesson_4/Task_2/Program.cs +++ b/Lesson_4/Task_2/Program.cs @@ -1,2 +1,5 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); +using Open_Closed.Classes; + +(new FireMagic()).CountYourMagic(); +(new WaterMagic()).CountYourMagic(); +(new UnknownMagic()).CountYourMagic(); 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