Update Lesson 4 Task 2

This commit is contained in:
Stanislav Mykhailenko 2023-04-16 15:30:25 +03:00
parent c20ce64cce
commit b64a9ea7b9
GPG key ID: 1E95E66A9C9D6A36
5 changed files with 12 additions and 32 deletions

View file

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

View file

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Open_Closed.Interfaces;
namespace Open_Closed.Classes
{
public abstract class Magic : IMagic
{
public abstract int MagicValue { get; }
public abstract string MagicType { get; }
public void CountYourMagic()
{
Console.WriteLine($"Your magic is {MagicType}.");
}
}
}

View file

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

View file

@ -8,9 +8,11 @@ namespace Open_Closed.Interfaces
{
public interface IMagic
{
abstract int MagicValue { get; }
abstract string MagicType { get; }
string MagicType { get; }
void CountYourMagic();
public void CountYourMagic()
{
Console.WriteLine($"Your magic is {MagicType}.");
}
}
}

View file

@ -1,4 +1,5 @@
using Open_Closed.Classes;
using Open_Closed.Interfaces;
(new FireMagic()).CountYourMagic();
(new WaterMagic()).CountYourMagic();
((IMagic) new FireMagic()).CountYourMagic();
((IMagic) new WaterMagic()).CountYourMagic();