Update Lesson 4 Task 2
This commit is contained in:
parent
39d4c9a4d1
commit
4df251331d
6 changed files with 17 additions and 25 deletions
|
@ -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"; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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();
|
||||||
|
|
Reference in a new issue