Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shkarpitskij aleksandr nikolaevich #14

Open
wants to merge 12 commits into
base: Shkarpitskij_Aleksandr_Nikolaevich
Choose a base branch
from
134 changes: 134 additions & 0 deletions CourseApp.Tests/CharacterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
namespace CourseApp.Tests
{
using Character;
using Xunit;

public class CharacterTest
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved
{
[Fact]

public void TestGur()
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved
{
var guard = new Guardian("Leo", "zweihender", 95);
Assert.Equal("zweihender", guard.TypeOfWeapon);
Assert.Equal(95, guard.Lvl);
}

[Fact]

Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved
public void TestMag()
{
var magian = new TheMagian("Rise", "CristalStaff", 85);
Assert.Equal("Rise", magian.Name);
Assert.Equal("CristalStaff", magian.TypeOfWeapon);
Assert.Equal(85, magian.Lvl);
}

[Fact]

public void TestArcher()
{
var archer = new Archer("Azir", "Black Onion", 79);
Assert.Equal("Azir", archer.Name);
Assert.Equal("Black Onion", archer.TypeOfWeapon);
Assert.Equal(79, archer.Lvl);
}

[Fact]

public void TestArcherGetInfo()
{
var arch = new Archer("Azir", "Black Onion", 79);
var res = arch.GetInfo();
Assert.Equal("Я заступил на службу в 12:00 ", res);
Character archer = arch; // ссылка типа базового класса на дочерний
Assert.Equal(res, archer.GetInfo());
}

[Fact]

public void TestGuardianGetInfo()
{
var guar = new Guardian("Leo", "zweihender", 95);
var rs = guar.GetInfo();
Assert.Equal("Я работаю в элитных войсках короля Людовика 2 ", rs);
Character guard = guar;
Assert.Equal(rs, guard.GetInfo());
}

[Fact]

public void TestTheMagianGetInfo()
{
var mag = new TheMagian("Rise", "CristalStaff", 85);
var result = mag.GetInfo();
Assert.Equal("Я служу для защиты нашего прекрасного замка ", result);
Character magian = mag;
Assert.Equal(result, magian.GetInfo());
}

[Fact]
public void TestTheMagianToString()
{
var mag = new TheMagian("Rise", "CristalStaff", 85);
var result = mag.ToString();
Assert.Equal("Какой же красивый замок", result);
Character magian = mag;
Assert.Equal(result, magian.ToString());
}

[Fact]

public void TestArcherToString()
{
var ar = new Archer("Azir", "Black Onion", 79);
var resul = ar.ToString();
Assert.Equal("Ура у меня всё хорошо!", resul);
Character arc = ar;
Assert.Equal(resul, arc.ToString());
}

[Fact]

public void TestGuardianToString()
{
var gurd = new Guardian("Leo", "zweihender", 95);
var resul = gurd.ToString();
Assert.Equal("Как хорошо, что меня ещё не уволили)", resul);
Character gur = gurd;
Assert.Equal(resul, gur.ToString());
}

[Fact]

public void TestGuardianGuild()
{
var guard = new Guardian("Leo", "zweihender", 95);
var result = guard.Guild();
Assert.Equal("я состою в гильдии Пылающий Вепрь", result);
Character gur = guard;
Assert.Equal(result, gur.Guild());
}

[Fact]

public void TestArcherGuild()
{
var archer = new Archer("Azir", "Black Onion", 79);
var resul = archer.Guild();
Assert.Equal("я состою в гильдии Милость Дриады", resul);
Character arc = archer;
Assert.Equal(resul, arc.Guild());
}

[Fact]
public void TestTheMagianGuild()
{
var mag = new TheMagian("Rise", "CristalStaff", 85);
var result = mag.Guild();
Assert.Equal("я состою в гильдии Банши", result);
Character magian = mag;
Assert.Equal(result, magian.Guild());
}
}
}
13 changes: 0 additions & 13 deletions CourseApp.Tests/DemoTest.cs

This file was deleted.

54 changes: 54 additions & 0 deletions CourseApp/Character/Archer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace Character;

using System;

public class Archer : Character
{
private static string bw = "Bow of the erd tree";

public Archer(string name, string typeOfWeapon, int lvl)
: base(name, typeOfWeapon, lvl)
{
}

public static void Bow(string bow)
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved
{
if (bow == bw)
{
Ability(100);
}
else
{
Ability(80);
}
}

public static void Ability(int arrows)
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved
{
if (arrows < 90)
{
Console.WriteLine("Azir тебе разрешено защищать только стены города");
Console.WriteLine();
}
else
{
Console.WriteLine("Azir тебе разрешено защищать саму принцессу");
Console.WriteLine();
}
}

public override string Guild()
{
return "я состою в гильдии Милость Дриады";
}

public override string GetInfo()
{
return $"Я заступил на службу в 12:00 ";
}

public override string ToString()
{
return "Ура у меня всё хорошо!";
}
}
60 changes: 60 additions & 0 deletions CourseApp/Character/Character.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace Character;

using System;

public abstract class Character
{
private int level;

public Character(string name, string typeOfWeapon, int lvl)
{
this.Name = name;
this.TypeOfWeapon = typeOfWeapon;
this.Lvl = lvl;
}

public int Lvl
{
get
{
return level;
}

set
{
if (level < value)
{
level = value;
}
}
}

public string TypeOfWeapon { get; set; }

public string Name { get; set; }

public void Print()
{
Console.Write($"{Name} {Lvl} {TypeOfWeapon}");
}

public virtual string Guild()
{
return "1535";
}
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved

/*public void MaxLevel()
{
Console.WriteLine($"Ваш уровень {Lvl} /99");
}

public void Damag()
{
Console.WriteLine($"Вам выпало легендарный оружие {TypeOfWeapon}");
}*/
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved

public virtual string GetInfo()
Sasha1602 marked this conversation as resolved.
Show resolved Hide resolved
{
return "54891";
}
}
40 changes: 40 additions & 0 deletions CourseApp/Character/Guardian.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Character;

using System;

public class Guardian : Character
{
public Guardian(string name, string typeOfWeapon, int lvl)
: base(name, typeOfWeapon, lvl)
{
}

public void Protect(bool protect)
{
if (protect != true)
{
Console.WriteLine("Я не защищаю принцессу");
Console.WriteLine();
}
else
{
Console.WriteLine("Я защищаю принцессу");
Console.WriteLine();
}
}

public override string Guild()
{
return "я состою в гильдии Пылающий Вепрь";
}

public override string GetInfo()
{
return $"Я работаю в элитных войсках короля Людовика 2 ";
}

public override string ToString()
{
return "Как хорошо, что меня ещё не уволили)";
}
}
40 changes: 40 additions & 0 deletions CourseApp/Character/TheMagian.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace Character;

using System;

public class TheMagian : Character
{
public TheMagian(string name, string typeOfWeapon, int lvl)
: base(name, typeOfWeapon, lvl)
{
}

public void Opponent(int grupOfOpponent)
{
if (grupOfOpponent < 40)
{
Console.WriteLine($"Им не нужна моя помощь");
Console.WriteLine();
}
else
{
Console.WriteLine($"Им нужна моя помощь");
Console.WriteLine();
}
}

public override string Guild()
{
return "я состою в гильдии Банши";
}

public override string GetInfo()
{
return $"Я служу для защиты нашего прекрасного замка ";
}

public override string ToString()
{
return "Какой же красивый замок";
}
}
2 changes: 2 additions & 0 deletions CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading