Update Lesson 4 Task 2
This commit is contained in:
parent
c20ce64cce
commit
b64a9ea7b9
5 changed files with 12 additions and 32 deletions
|
@ -8,9 +8,8 @@ using Open_Closed.Interfaces;
|
||||||
|
|
||||||
namespace Open_Closed.Classes
|
namespace Open_Closed.Classes
|
||||||
{
|
{
|
||||||
public class FireMagic : Magic, IMagic
|
public class FireMagic : IMagic
|
||||||
{
|
{
|
||||||
public override int MagicValue { get { return 150; } }
|
public string MagicType { get { return "fire"; } }
|
||||||
public override string MagicType { get { return "fire"; } }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,9 +8,8 @@ using Open_Closed.Interfaces;
|
||||||
|
|
||||||
namespace Open_Closed.Classes
|
namespace Open_Closed.Classes
|
||||||
{
|
{
|
||||||
public class WaterMagic : Magic, IMagic
|
public class WaterMagic : IMagic
|
||||||
{
|
{
|
||||||
public override int MagicValue { get { return 50000000; } }
|
public string MagicType { get { return "water"; } }
|
||||||
public override string MagicType { get { return "water"; } }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,11 @@ namespace Open_Closed.Interfaces
|
||||||
{
|
{
|
||||||
public interface IMagic
|
public interface IMagic
|
||||||
{
|
{
|
||||||
abstract int MagicValue { get; }
|
string MagicType { get; }
|
||||||
abstract string MagicType { get; }
|
|
||||||
|
|
||||||
void CountYourMagic();
|
public void CountYourMagic()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Your magic is {MagicType}.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Open_Closed.Classes;
|
using Open_Closed.Classes;
|
||||||
|
using Open_Closed.Interfaces;
|
||||||
|
|
||||||
(new FireMagic()).CountYourMagic();
|
((IMagic) new FireMagic()).CountYourMagic();
|
||||||
(new WaterMagic()).CountYourMagic();
|
((IMagic) new WaterMagic()).CountYourMagic();
|
||||||
|
|
Reference in a new issue