Update Lesson 4 Task 2

This commit is contained in:
Stanislav Mykhailenko 2023-04-15 23:25:41 +03:00
parent 39d4c9a4d1
commit 4df251331d
GPG key ID: 1E95E66A9C9D6A36
6 changed files with 17 additions and 25 deletions

View file

@ -8,9 +8,9 @@ using Open_Closed.Interfaces;
namespace Open_Closed.Classes namespace Open_Closed.Classes
{ {
public class FireMagic : IMagicClass public class FireMagic : Magic, IMagic
{ {
public int MagicValue { get { return 150; } } public override int MagicValue { get { return 150; } }
public string MagicType { get { return "fire"; } } public override string MagicType { get { return "fire"; } }
} }
} }

View file

@ -8,9 +8,12 @@ using Open_Closed.Interfaces;
namespace Open_Closed.Classes 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}."); Console.WriteLine($"Your magic is {MagicType}.");
} }

View file

@ -8,9 +8,9 @@ using Open_Closed.Interfaces;
namespace Open_Closed.Classes namespace Open_Closed.Classes
{ {
public class WaterMagic : IMagicClass public class WaterMagic : Magic, IMagic
{ {
public int MagicValue { get { return 50000000; } } public override int MagicValue { get { return 50000000; } }
public string MagicType { get { return "water"; } } public override string MagicType { get { return "water"; } }
} }
} }

View file

@ -8,6 +8,9 @@ namespace Open_Closed.Interfaces
{ {
public interface IMagic public interface IMagic
{ {
void CountYourMagic(string MagicType); abstract int MagicValue { get; }
abstract string MagicType { get; }
void CountYourMagic();
} }
} }

View file

@ -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; }
}
}

View file

@ -1,4 +1,4 @@
using Open_Closed.Classes; using Open_Closed.Classes;
(new Magic()).CountYourMagic(new FireMagic().MagicType); (new FireMagic()).CountYourMagic();
(new Magic()).CountYourMagic(new WaterMagic().MagicType); (new WaterMagic()).CountYourMagic();