Update Lesson 4 Task 2
This commit is contained in:
parent
0c61c25043
commit
92412bef42
6 changed files with 12 additions and 16 deletions
|
@ -10,9 +10,7 @@ namespace Open_Closed.Classes
|
|||
{
|
||||
public class FireMagic : IMagic
|
||||
{
|
||||
public void CountYourMagic()
|
||||
{
|
||||
Console.WriteLine("Wow, your magic is fire magic!");
|
||||
}
|
||||
public int MagicValue { get { return 150; } }
|
||||
public string MagicType { get { return "fire"; } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ using Open_Closed.Interfaces;
|
|||
|
||||
namespace Open_Closed.Classes
|
||||
{
|
||||
public class UnknownMagic : IMagic
|
||||
public class Magic
|
||||
{
|
||||
public void CountYourMagic()
|
||||
public void CountYourMagic(IMagic Magic)
|
||||
{
|
||||
Console.WriteLine("I understand you...");
|
||||
Console.WriteLine($"Your magic is {Magic.MagicType}.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,9 +10,7 @@ namespace Open_Closed.Classes
|
|||
{
|
||||
public class WaterMagic : IMagic
|
||||
{
|
||||
public void CountYourMagic()
|
||||
{
|
||||
Console.WriteLine("Incredible! You have 50 millions of power! It's water magic!");
|
||||
}
|
||||
public int MagicValue { get { return 50000000; } }
|
||||
public string MagicType { get { return "water"; } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Open_Closed.Interfaces
|
|||
{
|
||||
public interface IMagic
|
||||
{
|
||||
void CountYourMagic();
|
||||
int MagicValue { get; }
|
||||
string MagicType { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Open_Closed.Classes;
|
||||
|
||||
(new FireMagic()).CountYourMagic();
|
||||
(new WaterMagic()).CountYourMagic();
|
||||
(new UnknownMagic()).CountYourMagic();
|
||||
(new Magic()).CountYourMagic(new FireMagic());
|
||||
(new Magic()).CountYourMagic(new WaterMagic());
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
Reference in a new issue