Update Lesson 4 Task 2

This commit is contained in:
Stanislav Mykhailenko 2023-04-11 18:40:32 +03:00
parent 0c61c25043
commit 92412bef42
GPG key ID: 1E95E66A9C9D6A36
6 changed files with 12 additions and 16 deletions

View file

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

View file

@ -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}.");
}
}
}

View file

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

View file

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

View file

@ -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());

View file

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>