diff --git a/Lesson_4/Task_2/Classes/FireMagic.cs b/Lesson_4/Task_2/Classes/FireMagic.cs index 8842b59..c10a691 100644 --- a/Lesson_4/Task_2/Classes/FireMagic.cs +++ b/Lesson_4/Task_2/Classes/FireMagic.cs @@ -8,9 +8,9 @@ using Open_Closed.Interfaces; namespace Open_Closed.Classes { - public class FireMagic : IMagicClass + public class FireMagic : Magic, IMagic { - public int MagicValue { get { return 150; } } - public string MagicType { get { return "fire"; } } + public override int MagicValue { get { return 150; } } + public override string MagicType { get { return "fire"; } } } } diff --git a/Lesson_4/Task_2/Classes/Magic.cs b/Lesson_4/Task_2/Classes/Magic.cs index 2bb046f..fac03fc 100644 --- a/Lesson_4/Task_2/Classes/Magic.cs +++ b/Lesson_4/Task_2/Classes/Magic.cs @@ -8,9 +8,12 @@ using Open_Closed.Interfaces; namespace Open_Closed.Classes { - public class Magic : IMagic + abstract public class Magic : IMagic { - public void CountYourMagic(string MagicType) + abstract public int MagicValue { get; } + abstract public string MagicType { get; } + + public void CountYourMagic() { Console.WriteLine($"Your magic is {MagicType}."); } diff --git a/Lesson_4/Task_2/Classes/WaterMagic.cs b/Lesson_4/Task_2/Classes/WaterMagic.cs index aef7e32..6544e2b 100644 --- a/Lesson_4/Task_2/Classes/WaterMagic.cs +++ b/Lesson_4/Task_2/Classes/WaterMagic.cs @@ -8,9 +8,9 @@ using Open_Closed.Interfaces; namespace Open_Closed.Classes { - public class WaterMagic : IMagicClass + public class WaterMagic : Magic, IMagic { - public int MagicValue { get { return 50000000; } } - public string MagicType { get { return "water"; } } + public override int MagicValue { get { return 50000000; } } + public override string MagicType { get { return "water"; } } } } diff --git a/Lesson_4/Task_2/Interfaces/IMagic.cs b/Lesson_4/Task_2/Interfaces/IMagic.cs index d2599f7..ac64d46 100644 --- a/Lesson_4/Task_2/Interfaces/IMagic.cs +++ b/Lesson_4/Task_2/Interfaces/IMagic.cs @@ -8,6 +8,9 @@ namespace Open_Closed.Interfaces { public interface IMagic { - void CountYourMagic(string MagicType); + abstract int MagicValue { get; } + abstract string MagicType { get; } + + void CountYourMagic(); } } diff --git a/Lesson_4/Task_2/Interfaces/IMagicClass.cs b/Lesson_4/Task_2/Interfaces/IMagicClass.cs deleted file mode 100644 index 7a44e78..0000000 --- a/Lesson_4/Task_2/Interfaces/IMagicClass.cs +++ /dev/null @@ -1,14 +0,0 @@ -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/Program.cs b/Lesson_4/Task_2/Program.cs index 207c754..1f2dfcb 100644 --- a/Lesson_4/Task_2/Program.cs +++ b/Lesson_4/Task_2/Program.cs @@ -1,4 +1,4 @@ using Open_Closed.Classes; -(new Magic()).CountYourMagic(new FireMagic().MagicType); -(new Magic()).CountYourMagic(new WaterMagic().MagicType); +(new FireMagic()).CountYourMagic(); +(new WaterMagic()).CountYourMagic();