From 7d24737e09c8f0bae6e7f660760b4d04bb5809c2 Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Sat, 3 Sep 2022 12:32:52 +0300 Subject: [PATCH 01/11] 1 classes sample --- CourseApp/Phone.cs | 38 ++++++++++++++++++++++++++++++++++++++ CourseApp/Program.cs | 14 ++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 CourseApp/Phone.cs diff --git a/CourseApp/Phone.cs b/CourseApp/Phone.cs new file mode 100644 index 0000000..1c8e407 --- /dev/null +++ b/CourseApp/Phone.cs @@ -0,0 +1,38 @@ +namespace CourseApp +{ + using System; + + public class Phone + { + private float diaonal; + + public Phone(string name, float diagonal) + { + Name = name; + Diagonal = diagonal; + } + + public string Name { get; set; } + + public float Diagonal + { + get + { + return diaonal; + } + + set + { + if (value > 0 && value < 20) + { + this.diaonal = value; + } + } + } + + public void Show() + { + Console.WriteLine($"{Name} with diagonal {diaonal}"); + } + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index d6d2c87..030f047 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -6,6 +6,20 @@ public class Program { public static void Main(string[] args) { + Phone phone1 = new Phone("iPhone", -7); + phone1.Show(); + phone1.Diagonal = 7; + phone1.Show(); + phone1.Diagonal = -16; + phone1.Show(); + + Phone tablet = new Phone("Android", 6); + tablet.Diagonal = 6; + tablet.Show(); + tablet.Diagonal = -10; + tablet.Show(); + tablet.Diagonal = 8; + tablet.Show(); Console.WriteLine("Hello World"); } } From 448314d7a17f6e35e6d15f5404dd82634250bc48 Mon Sep 17 00:00:00 2001 From: Violettam88 Date: Mon, 31 Oct 2022 22:53:13 +0300 Subject: [PATCH 02/11] Task one done --- CourseApp/Phone.cs | 38 ----------- CourseApp/Program.cs | 23 +++---- CourseApp/Task_one/Country.cs | 119 ++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 53 deletions(-) delete mode 100644 CourseApp/Phone.cs create mode 100644 CourseApp/Task_one/Country.cs diff --git a/CourseApp/Phone.cs b/CourseApp/Phone.cs deleted file mode 100644 index 1c8e407..0000000 --- a/CourseApp/Phone.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace CourseApp -{ - using System; - - public class Phone - { - private float diaonal; - - public Phone(string name, float diagonal) - { - Name = name; - Diagonal = diagonal; - } - - public string Name { get; set; } - - public float Diagonal - { - get - { - return diaonal; - } - - set - { - if (value > 0 && value < 20) - { - this.diaonal = value; - } - } - } - - public void Show() - { - Console.WriteLine($"{Name} with diagonal {diaonal}"); - } - } -} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 030f047..c185350 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -6,21 +6,14 @@ public class Program { public static void Main(string[] args) { - Phone phone1 = new Phone("iPhone", -7); - phone1.Show(); - phone1.Diagonal = 7; - phone1.Show(); - phone1.Diagonal = -16; - phone1.Show(); - - Phone tablet = new Phone("Android", 6); - tablet.Diagonal = 6; - tablet.Show(); - tablet.Diagonal = -10; - tablet.Show(); - tablet.Diagonal = 8; - tablet.Show(); - Console.WriteLine("Hello World"); + Country one = new Country(); + Country two = new Country("Brazil", 121321, 3213); + one.Info(); + two.Info(); + one.ChangeArea(); + two.Population = 500; + two.Population = -500; + one.Info(); } } } diff --git a/CourseApp/Task_one/Country.cs b/CourseApp/Task_one/Country.cs new file mode 100644 index 0000000..86f6075 --- /dev/null +++ b/CourseApp/Task_one/Country.cs @@ -0,0 +1,119 @@ +namespace CourseApp +{ + using System; + + public class Country + { + private string name; + + private int population; + + private int square; + + public Country(string inName, int inPop, int inSquare) + { + Name = inName; + Population = inPop; + Square = inSquare; + } + + public Country() + { + Name = "Russia"; + Population = 145478097; + Square = 17125191; + } + + public string Name + { + get + { + return name; + } + + set + { + name = value; + } + } + + public int Population + { + get + { + return population; + } + + set + { + if (value <= 0) + { + Console.WriteLine("Incorrect value of population."); + } + else + { + population = value; + } + } + } + + public int Square + { + get + { + return square; + } + + set + { + if (value <= 0) + { + Console.WriteLine("Incorrect value of area."); + } + else + { + square = value; + } + } + } + + public void Info() + { + Console.WriteLine($"The country of {Name} has a population of {Population} people and an area of {Square} km^2"); + } + + public void ChangePopulation() + { + Random rnd = new Random(); + if (rnd.Next(0, 1) == 1) + { + int buffer = rnd.Next(1, 32768); + population += buffer; + Console.WriteLine($"{buffer} people were born. Now in the country {Population} people"); + } + else + { + int buffer = rnd.Next(1, 32768); + population -= buffer; + Console.WriteLine($"{buffer} people were died. Now in the country {Population} people."); + } + } + + public void ChangeArea() + { + Random rnd = new Random(); + if (rnd.Next(0, 1) == 1) + { + int buffer = rnd.Next(1, 10000); + Square -= buffer; + Console.WriteLine($"The area of the country has decreased by {buffer} km^2. Now the area of the country {Square}."); + } + else + { + int buffer = rnd.Next(1, 10000); + Square += buffer; + Console.WriteLine($"The area of the country has increased by {buffer} km^2. Now the area of the country {Square}."); + } + } + } +} \ No newline at end of file From e47832b695f9459d8702565597d3a0fca1e0db4e Mon Sep 17 00:00:00 2001 From: Violettam88 Date: Tue, 1 Nov 2022 14:25:05 +0300 Subject: [PATCH 03/11] some edition in program.cs, created unit test --- CourseApp.Tests/DemoTest.cs | 13 ------ CourseApp.Tests/Task_one/CountryTests.cs | 52 ++++++++++++++++++++++++ CourseApp/Program.cs | 3 +- CourseApp/Task_one/Country.cs | 2 +- 4 files changed, 54 insertions(+), 16 deletions(-) delete mode 100644 CourseApp.Tests/DemoTest.cs create mode 100644 CourseApp.Tests/Task_one/CountryTests.cs diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs deleted file mode 100644 index cf7cbb1..0000000 --- a/CourseApp.Tests/DemoTest.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CourseApp.Tests -{ - using Xunit; - - public class DemoTest - { - [Fact] - public void Test1() - { - Assert.True(true); - } - } -} diff --git a/CourseApp.Tests/Task_one/CountryTests.cs b/CourseApp.Tests/Task_one/CountryTests.cs new file mode 100644 index 0000000..10e36a9 --- /dev/null +++ b/CourseApp.Tests/Task_one/CountryTests.cs @@ -0,0 +1,52 @@ +namespace CourseApp.Tests.Task_one +{ + using System; + using System.IO; + using CourseApp.Task_one; + using Xunit; + + [Collection("Sequential")] + public class CountryTests : IDisposable + { + private const string Inp1 = "England 121321 3213"; + + private const string Out1 = @"The country of England has a population of 121321 people and an area of 3213 km^2 +Incorrect value of population. +Incorrect value of area. +The country of England has a population of 121321 people and an area of 15 km^2 +"; + + public void Dispose() + { + var standardOut = new StreamWriter(Console.OpenStandardOutput()); + standardOut.AutoFlush = true; + var standardIn = new StreamReader(Console.OpenStandardInput()); + Console.SetOut(standardOut); + Console.SetIn(standardIn); + } + + [Theory] + [InlineData(Inp1, Out1)] + public void EditingWithAndWithoutErorrs(string input, string expected) + { + var stringWriter = new StringWriter(); + Console.SetOut(stringWriter); + + var stringReader = new StringReader(input); + Console.SetIn(stringReader); + + // act + string[] buff = input.Split(' '); + Country one = new Country(buff[0], int.Parse(buff[1]), int.Parse(buff[2])); + one.Info(); + one.Population = -15; + one.Square = 0; + one.Square = 15; + one.Info(); + + // assert + var output = stringWriter.ToString(); + Assert.Equal($"{expected}", output); + } + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index c185350..1489972 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,6 +1,5 @@ -namespace CourseApp +namespace CourseApp.Task_one { - using System; public class Program { diff --git a/CourseApp/Task_one/Country.cs b/CourseApp/Task_one/Country.cs index 86f6075..e6b70c0 100644 --- a/CourseApp/Task_one/Country.cs +++ b/CourseApp/Task_one/Country.cs @@ -1,4 +1,4 @@ -namespace CourseApp +namespace CourseApp.Task_one { using System; From a39869ef49e659f55830ada735e168d36b0c9f3e Mon Sep 17 00:00:00 2001 From: Violettam88 Date: Tue, 1 Nov 2022 15:16:51 +0300 Subject: [PATCH 04/11] done task 2 --- CourseApp/Program.cs | 17 +++------ CourseApp/Task_two/Country.cs | 72 +++++++++++++++++++++++++++++++++++ CourseApp/Task_two/England.cs | 53 ++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 11 deletions(-) create mode 100644 CourseApp/Task_two/Country.cs create mode 100644 CourseApp/Task_two/England.cs diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 1489972..1391ba0 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,18 +1,13 @@ -namespace CourseApp.Task_one +namespace CourseApp.Task_two { - public class Program { public static void Main(string[] args) { - Country one = new Country(); - Country two = new Country("Brazil", 121321, 3213); - one.Info(); - two.Info(); - one.ChangeArea(); - two.Population = 500; - two.Population = -500; - one.Info(); + England test = new England(); + test.Info(); + test.ChangeArea(); + test.ChangePopulation(); } } -} +} \ No newline at end of file diff --git a/CourseApp/Task_two/Country.cs b/CourseApp/Task_two/Country.cs new file mode 100644 index 0000000..f92ece5 --- /dev/null +++ b/CourseApp/Task_two/Country.cs @@ -0,0 +1,72 @@ +namespace CourseApp.Task_two +{ + using System; + + public abstract class Country + { + private string name; + + private int population; + + private int square; + + public string Name + { + get + { + return name; + } + + set + { + name = value; + } + } + + public int Population + { + get + { + return population; + } + + set + { + if (value <= 0) + { + Console.WriteLine("Incorrect value of population."); + } + else + { + population = value; + } + } + } + + public int Square + { + get + { + return square; + } + + set + { + if (value <= 0) + { + Console.WriteLine("Incorrect value of area."); + } + else + { + square = value; + } + } + } + + public abstract void Info(); + + public abstract void ChangePopulation(); + + public abstract void ChangeArea(); + } +} \ No newline at end of file diff --git a/CourseApp/Task_two/England.cs b/CourseApp/Task_two/England.cs new file mode 100644 index 0000000..28293d5 --- /dev/null +++ b/CourseApp/Task_two/England.cs @@ -0,0 +1,53 @@ +namespace CourseApp.Task_two +{ + using System; + + public class England : Country + { + public England() + { + Name = "England"; + Population = 55980000; + Square = 130279; + } + + public override void Info() + { + Console.WriteLine($"The country of England has a population of {Population} people and an area of {Square} km^2"); + } + + public override void ChangePopulation() + { + Random rnd = new Random(); + if (rnd.Next(0, 1) == 1) + { + int buffer = rnd.Next(1, 32768); + Population += buffer; + Console.WriteLine($"{buffer} people were born. Now in the country {Population} people"); + } + else + { + int buffer = rnd.Next(1, 32768); + Population -= buffer; + Console.WriteLine($"{buffer} people were died. Now in the country {Population} people."); + } + } + + public override void ChangeArea() + { + Random rnd = new Random(); + if (rnd.Next(0, 1) == 1) + { + int buffer = rnd.Next(1, 10000); + Square -= buffer; + Console.WriteLine($"The area of the country has decreased by {buffer} km^2. Now the area of the country {Square}."); + } + else + { + int buffer = rnd.Next(1, 10000); + Square += buffer; + Console.WriteLine($"The area of the country has increased by {buffer} km^2. Now the area of the country {Square}."); + } + } + } +} From 2f52ffdb7e7875da9b0f2b3707e4f404f3759799 Mon Sep 17 00:00:00 2001 From: Violettam88 <92202628+Violettam88@users.noreply.github.com> Date: Mon, 19 Dec 2022 01:01:19 +0300 Subject: [PATCH 05/11] Create n_1_player --- saga/n_1_player | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 saga/n_1_player diff --git a/saga/n_1_player b/saga/n_1_player new file mode 100644 index 0000000..3dde202 --- /dev/null +++ b/saga/n_1_player @@ -0,0 +1,92 @@ +namespace CourseApp +{ + public abstract class Player + { + private bool sharpclaws; + + private bool сrimsonlight; + + public Player(int health, int inputS, string name, string ability) + { + MaxH = health; + NowH = health; + Strength = inputS; + Name = name; + AbilityName = ability; + AbilityLeft = 1; + sharpclaws = false; + сrimsonlight = false; + } + + public float MaxH { get; protected set; } + + public float NowH { get; protected set; } + + public float Strength { get; protected set; } + + public string Name { get; protected set; } + + public int AbilityLeft { get; protected set; } + + public string AbilityName { get; protected set; } + + public abstract string Ability(); + + public float Attack() + { + return Strength; + } + + public bool Damage(float damage) + { + NowH -= damage; + return IsDeath(); + } + + public void Debaff(string debuffName) + { + if (debuffName == "Острые коготки") + { + sharpclaws = true; + } + else if (debuffName == "Малиновый свет") + { + сrimsonlight = true; + } + } + + public string DebaffInfo() + { + if (sharpclaws) + { + sharpclaws = false; + return "Острые коготки"; + } + else if (сrimsonlight) + { + Damage(2); + return "Малиновый свет"; + } + + return string.Empty; + } + + public bool IsDeath() + { + if (NowH <= 0) + { + return true; + } + + return false; + } + + public void Update() + { + AbilityLeft = 1; + NowH = MaxH; + сrimsonlight = false; + sharpclaws = false; + } + } +} From 32770b5175542ec8ca1916b96cac658f960f3718 Mon Sep 17 00:00:00 2001 From: Violettam88 <92202628+Violettam88@users.noreply.github.com> Date: Mon, 19 Dec 2022 01:03:33 +0300 Subject: [PATCH 06/11] Add files via upload --- saga/Archer (2).cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 saga/Archer (2).cs diff --git a/saga/Archer (2).cs b/saga/Archer (2).cs new file mode 100644 index 0000000..8af8c04 --- /dev/null +++ b/saga/Archer (2).cs @@ -0,0 +1,30 @@ +namespace CourseApp +{ + using System; + + public class Archer : Player + { + public Archer(int health, int strength, string name) + : base(health, strength, name, "Cтрелы любви") + { + } + + public override string ToString() + { + return "(Лучница) " + Name; + } + + public override string Ability() + { + if (AbilityLeft > 0) + { + AbilityLeft--; + return AbilityName; + } + else + { + return "нанесла урон"; + } + } + } +} \ No newline at end of file From 30c33b44a8d669c9729e153512049a899bd1213b Mon Sep 17 00:00:00 2001 From: Violettam88 <92202628+Violettam88@users.noreply.github.com> Date: Mon, 19 Dec 2022 01:04:07 +0300 Subject: [PATCH 07/11] Delete n_1_player --- saga/n_1_player | 92 ------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 saga/n_1_player diff --git a/saga/n_1_player b/saga/n_1_player deleted file mode 100644 index 3dde202..0000000 --- a/saga/n_1_player +++ /dev/null @@ -1,92 +0,0 @@ -namespace CourseApp -{ - public abstract class Player - { - private bool sharpclaws; - - private bool сrimsonlight; - - public Player(int health, int inputS, string name, string ability) - { - MaxH = health; - NowH = health; - Strength = inputS; - Name = name; - AbilityName = ability; - AbilityLeft = 1; - sharpclaws = false; - сrimsonlight = false; - } - - public float MaxH { get; protected set; } - - public float NowH { get; protected set; } - - public float Strength { get; protected set; } - - public string Name { get; protected set; } - - public int AbilityLeft { get; protected set; } - - public string AbilityName { get; protected set; } - - public abstract string Ability(); - - public float Attack() - { - return Strength; - } - - public bool Damage(float damage) - { - NowH -= damage; - return IsDeath(); - } - - public void Debaff(string debuffName) - { - if (debuffName == "Острые коготки") - { - sharpclaws = true; - } - else if (debuffName == "Малиновый свет") - { - сrimsonlight = true; - } - } - - public string DebaffInfo() - { - if (sharpclaws) - { - sharpclaws = false; - return "Острые коготки"; - } - else if (сrimsonlight) - { - Damage(2); - return "Малиновый свет"; - } - - return string.Empty; - } - - public bool IsDeath() - { - if (NowH <= 0) - { - return true; - } - - return false; - } - - public void Update() - { - AbilityLeft = 1; - NowH = MaxH; - сrimsonlight = false; - sharpclaws = false; - } - } -} From f7d754ef84cd71e4e46e1ade25e4e20c30898479 Mon Sep 17 00:00:00 2001 From: Violettam88 <92202628+Violettam88@users.noreply.github.com> Date: Mon, 19 Dec 2022 01:04:41 +0300 Subject: [PATCH 08/11] Add files via upload --- saga/Game (2).cs | 185 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 saga/Game (2).cs diff --git a/saga/Game (2).cs b/saga/Game (2).cs new file mode 100644 index 0000000..8cf1563 --- /dev/null +++ b/saga/Game (2).cs @@ -0,0 +1,185 @@ +namespace CourseApp +{ + using System; + using System.Collections.Generic; + using System.Linq; + + public class Game + { + public static void Play() + { + int num = AskNum(); + List playerList = PlayersList(num); + RNDList(ref playerList); + PlayGame(ref playerList); + } + + private static void PlayGame(ref List playerList) + { + for (int i = 1; playerList.Count != 1; i++) + { + Logger.Write(i); + PlayRound(ref playerList); + } + + Logger.Write(playerList[0]); + } + + private static void PlayRound(ref List playerList) + { + for (int i = 0; i < playerList.Count / 2; i++) + { + Logger.Write(playerList[i * 2], playerList[(i * 2) + 1]); + playerList[i * 2] = Fight(playerList[i * 2], playerList[(i * 2) + 1]); + } + + for (int i = 1; i < playerList.Count; i++) + { + playerList.RemoveAt(i); + } + } + + private static Player Fight(Player first, Player second) + { + for (int i = 0; true; i++) + { + if (i != 0) + { + (first, second) = (second, first); + } + + string debaffinf = first.DebaffInfo(); + Logger.Write(first, debaffinf); + bool checkDeath = first.IsDeath(); + if (checkDeath) + { + Logger.Write(first, true); + second.Update(); + return second; + } + + if (debaffinf == "Заколдованная пыль") + { + continue; + } + + string action = PlayerAct(); + if (action == "ab") + { + var actionisdone = first.Ability(); + if (actionisdone != "нанесла урон") + { + if (actionisdone == "Розовый удар") + { + Logger.Write(first, second, actionisdone, (float)Math.Round(first.Attack() * 1.3f, 2)); + second.Damage((float)Math.Round(first.Attack() * 1.3f, 2)); + } + else + { + Logger.Write(first, second, actionisdone); + second.Debaff(actionisdone); + } + } + else + { + Logger.Write(first, second, actionisdone, first.Attack()); + second.Damage(first.Attack()); + } + } + else + { + Logger.Write(first, second, "нанесла урон", first.Attack()); + second.Damage(first.Attack()); + } + + checkDeath = second.IsDeath(); + if (checkDeath) + { + Logger.Write(second, true); + first.Update(); + return first; + } + } + } + + private static string PlayerAct() + { + Random rnd = new Random(); + int action = rnd.Next(0, 2); + if (action == 0) + { + return "ab"; + } + else + { + return "at"; + } + } + + private static int AskNum() + { + while (true) + { + Console.WriteLine("Введите четное количество игроков:"); + int number = Convert.ToInt32(Console.ReadLine()); + if (number <= 0) + { + Console.WriteLine("КАКОЕ НОЛЬ, КАК ИХ МЕНЬШЕ 2 МОЖЕТ БЫТЬ!"); + } + else if (number % 2 != 0) + { + Console.WriteLine("ЧЕТНОЕ ДАЙ МНЕ!"); + } + else + { + return number; + } + } + } + + private static void RNDList(ref List input) + { + Random rnd = new Random(); + Player[] buffer = input.ToArray(); + for (int i = 0; i < input.Count; i++) + { + int pos = rnd.Next(i, buffer.Length); + (buffer[i], buffer[pos]) = (buffer[pos], buffer[i]); + } + + input = buffer.ToList(); + } + + private static List PlayersList(int count) + { + List players = new List(); + for (int i = 0; i < count; i++) + { + players.Add(PGen()); + } + + return players; + } + + private static Player PGen() + { + Random rnd = new Random(); + string[] name = { "Колмезер", "Мэлдебель", "Сьюбексика", "Вилоура", "Бонреетта", "Эрсэн", "Челриция", "Антлейси", "Кейоан", "Хоуелоун", "Дамсзен", "Анжиия", "Глозетда" }; + int health = rnd.Next(1, 50); + int strength = rnd.Next(1, 20); + int classChouse = rnd.Next(0, 3); + if (classChouse == 0) + { + return new Warrior(health, strength, name[rnd.Next(name.Length)]); + } + else if (classChouse == 1) + { + return new Mage(health, strength, name[rnd.Next(name.Length)]); + } + else + { + return new Archer(health, strength, name[rnd.Next(name.Length)]); + } + } + } +} \ No newline at end of file From eb75728d0485e07d56518516e5e5922b31f4268b Mon Sep 17 00:00:00 2001 From: Violettam88 <92202628+Violettam88@users.noreply.github.com> Date: Mon, 19 Dec 2022 01:05:53 +0300 Subject: [PATCH 09/11] Add files via upload --- saga/Logger (2).cs | 62 +++++++++++++++++++++++++++++++++++++++++++++ saga/Mage (2).cs | 30 ++++++++++++++++++++++ saga/Program (2).cs | 10 ++++++++ saga/Warrior (2).cs | 30 ++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 saga/Logger (2).cs create mode 100644 saga/Mage (2).cs create mode 100644 saga/Program (2).cs create mode 100644 saga/Warrior (2).cs diff --git a/saga/Logger (2).cs b/saga/Logger (2).cs new file mode 100644 index 0000000..a54a922 --- /dev/null +++ b/saga/Logger (2).cs @@ -0,0 +1,62 @@ +namespace CourseApp +{ + using System; + using System.Collections.Generic; + + public static class Logger + { + public static void Write(Player winner) + { + Console.WriteLine($"{winner.ToString()} ПОБЕДИЛА!"); + } + + public static void Write(int round) + { + Console.WriteLine($"Раунд {round}"); + } + + public static void Write(Player first, Player second) + { + Console.WriteLine($"{first.ToString()} VS {second.ToString()}"); + } + + public static void Write(Player first, Player second, string action) + { + Console.WriteLine($"{first.ToString()} применила ({action}) по противнику {second.ToString()}"); + } + + public static void Write(Player first, Player second, string action, float damage) + { + if (action != "нанесла урон") + { + Console.WriteLine($"{first.ToString()} применила ({action}) и нанесла урон {damage} противнику {second.ToString()}"); + } + else + { + Console.WriteLine($"{first.ToString()} нанесла урон {damage} противнику {second.ToString()}"); + } + } + + public static void Write(Player inputP, string debaff) + { + switch (debaff) + { + case "Cтрелы любви": + Console.WriteLine($"{inputP.ToString()} получила периодический урон 2 от ({debaff})"); + break; + case "Заколдованная пыль": + Console.WriteLine($"{inputP.ToString()} пропустила ход из-за ({debaff})"); + break; + } + } + + public static void Write(Player inputP, bool isDeath) + { + if (isDeath) + { + Console.WriteLine($"{inputP.ToString()} погибла :)"); + Console.WriteLine(); + } + } + } +} \ No newline at end of file diff --git a/saga/Mage (2).cs b/saga/Mage (2).cs new file mode 100644 index 0000000..9ebb0b1 --- /dev/null +++ b/saga/Mage (2).cs @@ -0,0 +1,30 @@ +namespace CourseApp +{ + using System; + + public class Mage : Player + { + public Mage(int health, int strength, string name) + : base(health, strength, name, "Заколдованная пыль") + { + } + + public override string ToString() + { + return "(Волшебница) " + Name; + } + + public override string Ability() + { + if (AbilityLeft > 0) + { + AbilityLeft--; + return AbilityName; + } + else + { + return "нанесла урон"; + } + } + } +} \ No newline at end of file diff --git a/saga/Program (2).cs b/saga/Program (2).cs new file mode 100644 index 0000000..ab7631d --- /dev/null +++ b/saga/Program (2).cs @@ -0,0 +1,10 @@ +namespace CourseApp +{ + public class Program + { + public static void Main(string[] args) + { + Game.Play(); + } + } +} diff --git a/saga/Warrior (2).cs b/saga/Warrior (2).cs new file mode 100644 index 0000000..e523f9c --- /dev/null +++ b/saga/Warrior (2).cs @@ -0,0 +1,30 @@ +namespace CourseApp +{ + using System; + + public class Warrior : Player + { + public Warrior(int health, int strength, string name) + : base(health, strength, name, "Розовый удар") + { + } + + public override string ToString() + { + return "(Воинша) " + Name; + } + + public override string Ability() + { + if (AbilityLeft > 0) + { + AbilityLeft--; + return AbilityName; + } + else + { + return "нанесла урон"; + } + } + } +} \ No newline at end of file From 2d69b2a447c15e66e340e8c4218a342bda795194 Mon Sep 17 00:00:00 2001 From: Violettam88 <92202628+Violettam88@users.noreply.github.com> Date: Mon, 19 Dec 2022 01:06:37 +0300 Subject: [PATCH 10/11] Add files via upload --- saga/Player (2).cs | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 saga/Player (2).cs diff --git a/saga/Player (2).cs b/saga/Player (2).cs new file mode 100644 index 0000000..c710f17 --- /dev/null +++ b/saga/Player (2).cs @@ -0,0 +1,95 @@ +namespace CourseApp +{ + using System; + using System.Collections.Generic; + + public abstract class Player + { + private bool enchantedDust; + + private bool loveArrow; + + public Player(int health, int inputS, string name, string ability) + { + MaxH = health; + NowH = health; + Strength = inputS; + Name = name; + AbilityName = ability; + AbilityLeft = 1; + enchantedDust = false; + loveArrow = false; + } + + public float MaxH { get; protected set; } + + public float NowH { get; protected set; } + + public float Strength { get; protected set; } + + public string Name { get; protected set; } + + public int AbilityLeft { get; protected set; } + + public string AbilityName { get; protected set; } + + public abstract string Ability(); + + public float Attack() + { + return Strength; + } + + public bool Damage(float damage) + { + NowH -= damage; + return IsDeath(); + } + + public void Debaff(string debuffName) + { + if (debuffName == "Заколдованная пыль") + { + enchantedDust = true; + } + else if (debuffName == "Cтрелы любви") + { + loveArrow = true; + } + } + + public string DebaffInfo() + { + if (enchantedDust) + { + enchantedDust = false; + return "Заколдованная пыль"; + } + else if (loveArrow) + { + Damage(2); + return "Cтрелы любви"; + } + + return string.Empty; + } + + public bool IsDeath() + { + if (NowH <= 0) + { + return true; + } + + return false; + } + + public void Update() + { + AbilityLeft = 1; + NowH = MaxH; + loveArrow = false; + enchantedDust = false; + } + } +} \ No newline at end of file From 7dd245514f6cd3ffcd1e9babfb96ee9bdd2470d0 Mon Sep 17 00:00:00 2001 From: Violettam88 Date: Fri, 13 Jan 2023 22:53:48 +0300 Subject: [PATCH 11/11] =?UTF-8?q?=D0=B7=D0=B0=D0=BB=D0=B8=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=BE=D1=80=D0=BC=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=20:(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CourseApp/Program.cs | 9 +- .../Archer (2).cs => CourseApp/Saga/Archer.cs | 58 +-- saga/Game (2).cs => CourseApp/Saga/Game.cs | 368 +++++++++--------- .../Logger (2).cs => CourseApp/Saga/Logger.cs | 122 +++--- saga/Mage (2).cs => CourseApp/Saga/Mage.cs | 58 +-- .../Player (2).cs => CourseApp/Saga/Player.cs | 188 ++++----- .../Saga/Warrior.cs | 58 +-- saga/Program (2).cs | 10 - 8 files changed, 429 insertions(+), 442 deletions(-) rename saga/Archer (2).cs => CourseApp/Saga/Archer.cs (95%) rename saga/Game (2).cs => CourseApp/Saga/Game.cs (96%) rename saga/Logger (2).cs => CourseApp/Saga/Logger.cs (97%) rename saga/Mage (2).cs => CourseApp/Saga/Mage.cs (95%) rename saga/Player (2).cs => CourseApp/Saga/Player.cs (95%) rename saga/Warrior (2).cs => CourseApp/Saga/Warrior.cs (95%) delete mode 100644 saga/Program (2).cs diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 1391ba0..78cb446 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,13 +1,10 @@ -namespace CourseApp.Task_two +namespace CourseApp { public class Program { public static void Main(string[] args) { - England test = new England(); - test.Info(); - test.ChangeArea(); - test.ChangePopulation(); + Game.Play(); } } -} \ No newline at end of file +} diff --git a/saga/Archer (2).cs b/CourseApp/Saga/Archer.cs similarity index 95% rename from saga/Archer (2).cs rename to CourseApp/Saga/Archer.cs index 8af8c04..9931624 100644 --- a/saga/Archer (2).cs +++ b/CourseApp/Saga/Archer.cs @@ -1,30 +1,30 @@ -namespace CourseApp -{ - using System; - - public class Archer : Player - { - public Archer(int health, int strength, string name) - : base(health, strength, name, "Cтрелы любви") - { - } - - public override string ToString() - { - return "(Лучница) " + Name; - } - - public override string Ability() - { - if (AbilityLeft > 0) - { - AbilityLeft--; - return AbilityName; - } - else - { - return "нанесла урон"; - } - } - } +namespace CourseApp +{ + using System; + + public class Archer : Player + { + public Archer(int health, int strength, string name) + : base(health, strength, name, "Cтрелы любви") + { + } + + public override string ToString() + { + return "(Лучница) " + Name; + } + + public override string Ability() + { + if (AbilityLeft > 0) + { + AbilityLeft--; + return AbilityName; + } + else + { + return "нанесла урон"; + } + } + } } \ No newline at end of file diff --git a/saga/Game (2).cs b/CourseApp/Saga/Game.cs similarity index 96% rename from saga/Game (2).cs rename to CourseApp/Saga/Game.cs index 8cf1563..ff98fba 100644 --- a/saga/Game (2).cs +++ b/CourseApp/Saga/Game.cs @@ -1,185 +1,185 @@ -namespace CourseApp -{ - using System; - using System.Collections.Generic; - using System.Linq; - - public class Game - { - public static void Play() - { - int num = AskNum(); - List playerList = PlayersList(num); - RNDList(ref playerList); - PlayGame(ref playerList); - } - - private static void PlayGame(ref List playerList) - { - for (int i = 1; playerList.Count != 1; i++) - { - Logger.Write(i); - PlayRound(ref playerList); - } - - Logger.Write(playerList[0]); - } - - private static void PlayRound(ref List playerList) - { - for (int i = 0; i < playerList.Count / 2; i++) - { - Logger.Write(playerList[i * 2], playerList[(i * 2) + 1]); - playerList[i * 2] = Fight(playerList[i * 2], playerList[(i * 2) + 1]); - } - - for (int i = 1; i < playerList.Count; i++) - { - playerList.RemoveAt(i); - } - } - - private static Player Fight(Player first, Player second) - { - for (int i = 0; true; i++) - { - if (i != 0) - { - (first, second) = (second, first); - } - - string debaffinf = first.DebaffInfo(); - Logger.Write(first, debaffinf); - bool checkDeath = first.IsDeath(); - if (checkDeath) - { - Logger.Write(first, true); - second.Update(); - return second; - } - - if (debaffinf == "Заколдованная пыль") - { - continue; - } - - string action = PlayerAct(); - if (action == "ab") - { - var actionisdone = first.Ability(); - if (actionisdone != "нанесла урон") - { - if (actionisdone == "Розовый удар") - { - Logger.Write(first, second, actionisdone, (float)Math.Round(first.Attack() * 1.3f, 2)); - second.Damage((float)Math.Round(first.Attack() * 1.3f, 2)); - } - else - { - Logger.Write(first, second, actionisdone); - second.Debaff(actionisdone); - } - } - else - { - Logger.Write(first, second, actionisdone, first.Attack()); - second.Damage(first.Attack()); - } - } - else - { - Logger.Write(first, second, "нанесла урон", first.Attack()); - second.Damage(first.Attack()); - } - - checkDeath = second.IsDeath(); - if (checkDeath) - { - Logger.Write(second, true); - first.Update(); - return first; - } - } - } - - private static string PlayerAct() - { - Random rnd = new Random(); - int action = rnd.Next(0, 2); - if (action == 0) - { - return "ab"; - } - else - { - return "at"; - } - } - - private static int AskNum() - { - while (true) - { - Console.WriteLine("Введите четное количество игроков:"); - int number = Convert.ToInt32(Console.ReadLine()); - if (number <= 0) - { - Console.WriteLine("КАКОЕ НОЛЬ, КАК ИХ МЕНЬШЕ 2 МОЖЕТ БЫТЬ!"); - } - else if (number % 2 != 0) - { - Console.WriteLine("ЧЕТНОЕ ДАЙ МНЕ!"); - } - else - { - return number; - } - } - } - - private static void RNDList(ref List input) - { - Random rnd = new Random(); - Player[] buffer = input.ToArray(); - for (int i = 0; i < input.Count; i++) - { - int pos = rnd.Next(i, buffer.Length); - (buffer[i], buffer[pos]) = (buffer[pos], buffer[i]); - } - - input = buffer.ToList(); - } - - private static List PlayersList(int count) - { - List players = new List(); - for (int i = 0; i < count; i++) - { - players.Add(PGen()); - } - - return players; - } - - private static Player PGen() - { - Random rnd = new Random(); - string[] name = { "Колмезер", "Мэлдебель", "Сьюбексика", "Вилоура", "Бонреетта", "Эрсэн", "Челриция", "Антлейси", "Кейоан", "Хоуелоун", "Дамсзен", "Анжиия", "Глозетда" }; - int health = rnd.Next(1, 50); - int strength = rnd.Next(1, 20); - int classChouse = rnd.Next(0, 3); - if (classChouse == 0) - { - return new Warrior(health, strength, name[rnd.Next(name.Length)]); - } - else if (classChouse == 1) - { - return new Mage(health, strength, name[rnd.Next(name.Length)]); - } - else - { - return new Archer(health, strength, name[rnd.Next(name.Length)]); - } - } - } +namespace CourseApp +{ + using System; + using System.Collections.Generic; + using System.Linq; + + public class Game + { + public static void Play() + { + int num = AskNum(); + List playerList = PlayersList(num); + RNDList(ref playerList); + PlayGame(ref playerList); + } + + private static void PlayGame(ref List playerList) + { + for (int i = 1; playerList.Count != 1; i++) + { + Logger.Write(i); + PlayRound(ref playerList); + } + + Logger.Write(playerList[0]); + } + + private static void PlayRound(ref List playerList) + { + for (int i = 0; i < playerList.Count / 2; i++) + { + Logger.Write(playerList[i * 2], playerList[(i * 2) + 1]); + playerList[i * 2] = Fight(playerList[i * 2], playerList[(i * 2) + 1]); + } + + for (int i = 1; i < playerList.Count; i++) + { + playerList.RemoveAt(i); + } + } + + private static Player Fight(Player first, Player second) + { + for (int i = 0; true; i++) + { + if (i != 0) + { + (first, second) = (second, first); + } + + string debaffinf = first.DebaffInfo(); + Logger.Write(first, debaffinf); + bool checkDeath = first.IsDeath(); + if (checkDeath) + { + Logger.Write(first, true); + second.Update(); + return second; + } + + if (debaffinf == "Заколдованная пыль") + { + continue; + } + + string action = PlayerAct(); + if (action == "ab") + { + var actionisdone = first.Ability(); + if (actionisdone != "нанесла урон") + { + if (actionisdone == "Розовый удар") + { + Logger.Write(first, second, actionisdone, (float)Math.Round(first.Attack() * 1.3f, 2)); + second.Damage((float)Math.Round(first.Attack() * 1.3f, 2)); + } + else + { + Logger.Write(first, second, actionisdone); + second.Debaff(actionisdone); + } + } + else + { + Logger.Write(first, second, actionisdone, first.Attack()); + second.Damage(first.Attack()); + } + } + else + { + Logger.Write(first, second, "нанесла урон", first.Attack()); + second.Damage(first.Attack()); + } + + checkDeath = second.IsDeath(); + if (checkDeath) + { + Logger.Write(second, true); + first.Update(); + return first; + } + } + } + + private static string PlayerAct() + { + Random rnd = new Random(); + int action = rnd.Next(0, 2); + if (action == 0) + { + return "ab"; + } + else + { + return "at"; + } + } + + private static int AskNum() + { + while (true) + { + Console.WriteLine("Введите четное количество игроков:"); + int number = Convert.ToInt32(Console.ReadLine()); + if (number <= 0) + { + Console.WriteLine("КАКОЕ НОЛЬ, КАК ИХ МЕНЬШЕ 2 МОЖЕТ БЫТЬ!"); + } + else if (number % 2 != 0) + { + Console.WriteLine("ЧЕТНОЕ ДАЙ МНЕ!"); + } + else + { + return number; + } + } + } + + private static void RNDList(ref List input) + { + Random rnd = new Random(); + Player[] buffer = input.ToArray(); + for (int i = 0; i < input.Count; i++) + { + int pos = rnd.Next(i, buffer.Length); + (buffer[i], buffer[pos]) = (buffer[pos], buffer[i]); + } + + input = buffer.ToList(); + } + + private static List PlayersList(int count) + { + List players = new List(); + for (int i = 0; i < count; i++) + { + players.Add(PGen()); + } + + return players; + } + + private static Player PGen() + { + Random rnd = new Random(); + string[] name = { "Колмезер", "Мэлдебель", "Сьюбексика", "Вилоура", "Бонреетта", "Эрсэн", "Челриция", "Антлейси", "Кейоан", "Хоуелоун", "Дамсзен", "Анжиия", "Глозетда" }; + int health = rnd.Next(1, 50); + int strength = rnd.Next(1, 20); + int classChouse = rnd.Next(0, 3); + if (classChouse == 0) + { + return new Warrior(health, strength, name[rnd.Next(name.Length)]); + } + else if (classChouse == 1) + { + return new Mage(health, strength, name[rnd.Next(name.Length)]); + } + else + { + return new Archer(health, strength, name[rnd.Next(name.Length)]); + } + } + } } \ No newline at end of file diff --git a/saga/Logger (2).cs b/CourseApp/Saga/Logger.cs similarity index 97% rename from saga/Logger (2).cs rename to CourseApp/Saga/Logger.cs index a54a922..451f576 100644 --- a/saga/Logger (2).cs +++ b/CourseApp/Saga/Logger.cs @@ -1,62 +1,62 @@ -namespace CourseApp -{ - using System; - using System.Collections.Generic; - - public static class Logger - { - public static void Write(Player winner) - { - Console.WriteLine($"{winner.ToString()} ПОБЕДИЛА!"); - } - - public static void Write(int round) - { - Console.WriteLine($"Раунд {round}"); - } - - public static void Write(Player first, Player second) - { - Console.WriteLine($"{first.ToString()} VS {second.ToString()}"); - } - - public static void Write(Player first, Player second, string action) - { - Console.WriteLine($"{first.ToString()} применила ({action}) по противнику {second.ToString()}"); - } - - public static void Write(Player first, Player second, string action, float damage) - { - if (action != "нанесла урон") - { - Console.WriteLine($"{first.ToString()} применила ({action}) и нанесла урон {damage} противнику {second.ToString()}"); - } - else - { - Console.WriteLine($"{first.ToString()} нанесла урон {damage} противнику {second.ToString()}"); - } - } - - public static void Write(Player inputP, string debaff) - { - switch (debaff) - { - case "Cтрелы любви": - Console.WriteLine($"{inputP.ToString()} получила периодический урон 2 от ({debaff})"); - break; - case "Заколдованная пыль": - Console.WriteLine($"{inputP.ToString()} пропустила ход из-за ({debaff})"); - break; - } - } - - public static void Write(Player inputP, bool isDeath) - { - if (isDeath) - { - Console.WriteLine($"{inputP.ToString()} погибла :)"); - Console.WriteLine(); - } - } - } +namespace CourseApp +{ + using System; + using System.Collections.Generic; + + public static class Logger + { + public static void Write(Player winner) + { + Console.WriteLine($"{winner.ToString()} ПОБЕДИЛА!"); + } + + public static void Write(int round) + { + Console.WriteLine($"Раунд {round}"); + } + + public static void Write(Player first, Player second) + { + Console.WriteLine($"{first.ToString()} VS {second.ToString()}"); + } + + public static void Write(Player first, Player second, string action) + { + Console.WriteLine($"{first.ToString()} применила ({action}) по противнику {second.ToString()}"); + } + + public static void Write(Player first, Player second, string action, float damage) + { + if (action != "нанесла урон") + { + Console.WriteLine($"{first.ToString()} применила ({action}) и нанесла урон {damage} противнику {second.ToString()}"); + } + else + { + Console.WriteLine($"{first.ToString()} нанесла урон {damage} противнику {second.ToString()}"); + } + } + + public static void Write(Player inputP, string debaff) + { + switch (debaff) + { + case "Cтрелы любви": + Console.WriteLine($"{inputP.ToString()} получила периодический урон 2 от ({debaff})"); + break; + case "Заколдованная пыль": + Console.WriteLine($"{inputP.ToString()} пропустила ход из-за ({debaff})"); + break; + } + } + + public static void Write(Player inputP, bool isDeath) + { + if (isDeath) + { + Console.WriteLine($"{inputP.ToString()} погибла :)"); + Console.WriteLine(); + } + } + } } \ No newline at end of file diff --git a/saga/Mage (2).cs b/CourseApp/Saga/Mage.cs similarity index 95% rename from saga/Mage (2).cs rename to CourseApp/Saga/Mage.cs index 9ebb0b1..6713daf 100644 --- a/saga/Mage (2).cs +++ b/CourseApp/Saga/Mage.cs @@ -1,30 +1,30 @@ -namespace CourseApp -{ - using System; - - public class Mage : Player - { - public Mage(int health, int strength, string name) - : base(health, strength, name, "Заколдованная пыль") - { - } - - public override string ToString() - { - return "(Волшебница) " + Name; - } - - public override string Ability() - { - if (AbilityLeft > 0) - { - AbilityLeft--; - return AbilityName; - } - else - { - return "нанесла урон"; - } - } - } +namespace CourseApp +{ + using System; + + public class Mage : Player + { + public Mage(int health, int strength, string name) + : base(health, strength, name, "Заколдованная пыль") + { + } + + public override string ToString() + { + return "(Волшебница) " + Name; + } + + public override string Ability() + { + if (AbilityLeft > 0) + { + AbilityLeft--; + return AbilityName; + } + else + { + return "нанесла урон"; + } + } + } } \ No newline at end of file diff --git a/saga/Player (2).cs b/CourseApp/Saga/Player.cs similarity index 95% rename from saga/Player (2).cs rename to CourseApp/Saga/Player.cs index c710f17..579fa11 100644 --- a/saga/Player (2).cs +++ b/CourseApp/Saga/Player.cs @@ -1,95 +1,95 @@ -namespace CourseApp -{ - using System; - using System.Collections.Generic; - - public abstract class Player - { - private bool enchantedDust; - - private bool loveArrow; - - public Player(int health, int inputS, string name, string ability) - { - MaxH = health; - NowH = health; - Strength = inputS; - Name = name; - AbilityName = ability; - AbilityLeft = 1; - enchantedDust = false; - loveArrow = false; - } - - public float MaxH { get; protected set; } - - public float NowH { get; protected set; } - - public float Strength { get; protected set; } - - public string Name { get; protected set; } - - public int AbilityLeft { get; protected set; } - - public string AbilityName { get; protected set; } - - public abstract string Ability(); - - public float Attack() - { - return Strength; - } - - public bool Damage(float damage) - { - NowH -= damage; - return IsDeath(); - } - - public void Debaff(string debuffName) - { - if (debuffName == "Заколдованная пыль") - { - enchantedDust = true; - } - else if (debuffName == "Cтрелы любви") - { - loveArrow = true; - } - } - - public string DebaffInfo() - { - if (enchantedDust) - { - enchantedDust = false; - return "Заколдованная пыль"; - } - else if (loveArrow) - { - Damage(2); - return "Cтрелы любви"; - } - - return string.Empty; - } - - public bool IsDeath() - { - if (NowH <= 0) - { - return true; - } - - return false; - } - - public void Update() - { - AbilityLeft = 1; - NowH = MaxH; - loveArrow = false; - enchantedDust = false; - } - } +namespace CourseApp +{ + using System; + using System.Collections.Generic; + + public abstract class Player + { + private bool enchantedDust; + + private bool loveArrow; + + public Player(int health, int inputS, string name, string ability) + { + MaxH = health; + NowH = health; + Strength = inputS; + Name = name; + AbilityName = ability; + AbilityLeft = 1; + enchantedDust = false; + loveArrow = false; + } + + public float MaxH { get; protected set; } + + public float NowH { get; protected set; } + + public float Strength { get; protected set; } + + public string Name { get; protected set; } + + public int AbilityLeft { get; protected set; } + + public string AbilityName { get; protected set; } + + public abstract string Ability(); + + public float Attack() + { + return Strength; + } + + public bool Damage(float damage) + { + NowH -= damage; + return IsDeath(); + } + + public void Debaff(string debuffName) + { + if (debuffName == "Заколдованная пыль") + { + enchantedDust = true; + } + else if (debuffName == "Cтрелы любви") + { + loveArrow = true; + } + } + + public string DebaffInfo() + { + if (enchantedDust) + { + enchantedDust = false; + return "Заколдованная пыль"; + } + else if (loveArrow) + { + Damage(2); + return "Cтрелы любви"; + } + + return string.Empty; + } + + public bool IsDeath() + { + if (NowH <= 0) + { + return true; + } + + return false; + } + + public void Update() + { + AbilityLeft = 1; + NowH = MaxH; + loveArrow = false; + enchantedDust = false; + } + } } \ No newline at end of file diff --git a/saga/Warrior (2).cs b/CourseApp/Saga/Warrior.cs similarity index 95% rename from saga/Warrior (2).cs rename to CourseApp/Saga/Warrior.cs index e523f9c..92fdb59 100644 --- a/saga/Warrior (2).cs +++ b/CourseApp/Saga/Warrior.cs @@ -1,30 +1,30 @@ -namespace CourseApp -{ - using System; - - public class Warrior : Player - { - public Warrior(int health, int strength, string name) - : base(health, strength, name, "Розовый удар") - { - } - - public override string ToString() - { - return "(Воинша) " + Name; - } - - public override string Ability() - { - if (AbilityLeft > 0) - { - AbilityLeft--; - return AbilityName; - } - else - { - return "нанесла урон"; - } - } - } +namespace CourseApp +{ + using System; + + public class Warrior : Player + { + public Warrior(int health, int strength, string name) + : base(health, strength, name, "Розовый удар") + { + } + + public override string ToString() + { + return "(Воинша) " + Name; + } + + public override string Ability() + { + if (AbilityLeft > 0) + { + AbilityLeft--; + return AbilityName; + } + else + { + return "нанесла урон"; + } + } + } } \ No newline at end of file diff --git a/saga/Program (2).cs b/saga/Program (2).cs deleted file mode 100644 index ab7631d..0000000 --- a/saga/Program (2).cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CourseApp -{ - public class Program - { - public static void Main(string[] args) - { - Game.Play(); - } - } -}