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 class FireMagic : IMagic
{ {
public void CountYourMagic() public int MagicValue { get { return 150; } }
{ public string MagicType { get { return "fire"; } }
Console.WriteLine("Wow, your magic is fire magic!");
}
} }
} }

View file

@ -8,11 +8,11 @@ using Open_Closed.Interfaces;
namespace Open_Closed.Classes 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 class WaterMagic : IMagic
{ {
public void CountYourMagic() public int MagicValue { get { return 50000000; } }
{ public string MagicType { get { return "water"; } }
Console.WriteLine("Incredible! You have 50 millions of power! It's water magic!");
}
} }
} }

View file

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

View file

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

View file

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