From 9acf321e0f1fe1707f0595717824b58b82dcaf36 Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 3 Oct 2019 08:46:32 +0300 Subject: [PATCH 1/9] Initial app --- .gitignore | 206 +++++++++++++++++++++++++ CourseApp.Tests/CourseApp.Tests.csproj | 30 ++++ CourseApp.Tests/DemoTest.cs | 14 ++ CourseApp/CourseApp.csproj | 23 +++ CourseApp/Program.cs | 13 ++ _stylecop/stylecop.json | 12 ++ _stylecop/stylecop.ruleset | 14 ++ courseworkspace.code-workspace | 11 ++ 8 files changed, 323 insertions(+) create mode 100644 .gitignore create mode 100644 CourseApp.Tests/CourseApp.Tests.csproj create mode 100644 CourseApp.Tests/DemoTest.cs create mode 100644 CourseApp/CourseApp.csproj create mode 100644 CourseApp/Program.cs create mode 100644 _stylecop/stylecop.json create mode 100644 _stylecop/stylecop.ruleset create mode 100644 courseworkspace.code-workspace diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35d4ccd --- /dev/null +++ b/.gitignore @@ -0,0 +1,206 @@ +# Download this file using PowerShell v3 under Windows with the following comand: +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore +# or wget: +# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +Icon? + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +# [Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# svn +.svn + +# Remainings from resolvings conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +**/node_modules/* + +# Added by Jskonst +.vscode/ +Properties/ + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### \ No newline at end of file diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj new file mode 100644 index 0000000..8fb7e4a --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp2.1 + True + 1573,1591,1701;1702;1705 + false + + + + + + + + + + + + + + + ../_stylecop/stylecop.ruleset + true + + + + + + + diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs new file mode 100644 index 0000000..fdc46f5 --- /dev/null +++ b/CourseApp.Tests/DemoTest.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace CourseApp.Tests +{ + public class DemoTest + { + [Fact] + public void Test1() + { + Assert.True(true); + } + } +} diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj new file mode 100644 index 0000000..b244e47 --- /dev/null +++ b/CourseApp/CourseApp.csproj @@ -0,0 +1,23 @@ + + + + Exe + netcoreapp2.1 + True + 1573,1591,1701;1702;1705; + + + + + + + + ../_stylecop/stylecop.ruleset + true + + + + + + + diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs new file mode 100644 index 0000000..248bbe4 --- /dev/null +++ b/CourseApp/Program.cs @@ -0,0 +1,13 @@ +using System; + +namespace CourseApp +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + Console.ReadLine(); + } + } +} diff --git a/_stylecop/stylecop.json b/_stylecop/stylecop.json new file mode 100644 index 0000000..4a96e8f --- /dev/null +++ b/_stylecop/stylecop.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "documentExposedElements": false, + "documentInterfaces": false, + "companyName": "Test Company", + "copyrightText": "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).", + "xmlHeader":false + } + } +} \ No newline at end of file diff --git a/_stylecop/stylecop.ruleset b/_stylecop/stylecop.ruleset new file mode 100644 index 0000000..98806c8 --- /dev/null +++ b/_stylecop/stylecop.ruleset @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/courseworkspace.code-workspace b/courseworkspace.code-workspace new file mode 100644 index 0000000..4f9af01 --- /dev/null +++ b/courseworkspace.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "CourseApp" + }, + { + "path": "CourseApp.Tests" + } + ], + "settings": {} +} \ No newline at end of file From 4bee2e33c9ee48d1ddd5155610a2abb29593cd9b Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 00:28:31 +0300 Subject: [PATCH 2/9] first version RPG --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- CourseApp/Program.cs | 15 ++- RPG.Tests/RPG.Tests.csproj | 30 +++++ RPG.Tests/RPGTests.cs | 103 +++++++++++++++ RPG/Archer.cs | 63 +++++++++ RPG/Game.cs | 170 +++++++++++++++++++++++++ RPG/Knight.cs | 48 +++++++ RPG/Logger.cs | 76 +++++++++++ RPG/Player.cs | 45 +++++++ RPG/Program.cs | 25 ++++ RPG/RPG.csproj | 10 ++ RPG/Wizard.cs | 41 ++++++ courseworkspace.code-workspace | 26 ++-- 14 files changed, 642 insertions(+), 14 deletions(-) create mode 100644 RPG.Tests/RPG.Tests.csproj create mode 100644 RPG.Tests/RPGTests.cs create mode 100644 RPG/Archer.cs create mode 100644 RPG/Game.cs create mode 100644 RPG/Knight.cs create mode 100644 RPG/Logger.cs create mode 100644 RPG/Player.cs create mode 100644 RPG/Program.cs create mode 100644 RPG/RPG.csproj create mode 100644 RPG/Wizard.cs diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 8fb7e4a..b5e64b9 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp3.0 True 1573,1591,1701;1702;1705 false diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index b244e47..1e655b8 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + netcoreapp3.0 True 1573,1591,1701;1702;1705; diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 248bbe4..8ba6b4d 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -6,8 +6,19 @@ public class Program { public static void Main(string[] args) { - Console.WriteLine("Hello World!"); - Console.ReadLine(); + Game game = new Game(); + Console.Write("Введите число героев: "); + + int numOfHeroes = Int32.Parse(Console.ReadLine()); + + if(numOfHeroes % 2 != 0) + { + numOfHeroes += 1; + } + + game.Start(numOfHeroes); + + Console.ReadKey(); } } } diff --git a/RPG.Tests/RPG.Tests.csproj b/RPG.Tests/RPG.Tests.csproj new file mode 100644 index 0000000..c278cda --- /dev/null +++ b/RPG.Tests/RPG.Tests.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp3.0 + True + 1573,1591,1701;1702;1705 + false + + + + + + + + + + + + + + + ../_stylecop/stylecop.ruleset + true + + + + + + + diff --git a/RPG.Tests/RPGTests.cs b/RPG.Tests/RPGTests.cs new file mode 100644 index 0000000..d63c920 --- /dev/null +++ b/RPG.Tests/RPGTests.cs @@ -0,0 +1,103 @@ +using System; +using Xunit; +using RPG; + +namespace RPG.Tests +{ + public class RPGTests + { + [Fact] + public void CreationTest() + { + Player knight = new Knight(); + Player archer = new Archer(); + Player wizard = new Wizard(); + + if (knight.Health > 0 && knight.Strength > 0 && archer.Health > 0 && archer.Strength > 0 && wizard.Health > 0 && wizard.Strength > 0) + { + Assert.True(true); + } + } + + [Fact] + public void KnightSkillsTest() + { + Player knight = new Knight(); + + int damage; + string skillName; + + knight.Skill(out skillName, out damage); + + if ((skillName == "Удар возмездия" || skillName == "Удар с размаху" || skillName == "Раскол земли") && damage > 0) + { + Assert.True(true); + } + } + + [Fact] + public void ArcherSkillsTest() + { + Player archer = new Archer(); + + int damage; + string skillName; + + archer.Skill(out skillName, out damage); + + if (skillName == "Огненные стрелы" && archer.buff && damage == 0) + { + Assert.True(true); + } + else if ((skillName == "Мощный выстрел" || skillName == "Град стрел") && damage > 0) + { + Assert.True(true); + } + } + + [Fact] + public void WizardSkillsTest() + { + Player wizard = new Wizard(); + + int damage; + string skillName; + + wizard.Skill(out skillName, out damage); + + if (skillName == "Заворожение" && wizard.sleepTime > 0 && damage == 0) + { + Assert.True(true); + } + else if (skillName == "Метеор" && damage > 0) + { + Assert.True(true); + } + } + + [Fact] + public void GetDamageTest() + { + Player wizard = new Wizard(); + + int health = wizard.GetDamage(30); + + Assert.Equal(wizard.maxHealth - 30, health); + } + + [Fact] + public void AtackTest() + { + Player archer = new Archer(); + + int damage; + + archer.Atack(out damage); + + if (damage > 0) + { + Assert.True(true); + } + } + } +} \ No newline at end of file diff --git a/RPG/Archer.cs b/RPG/Archer.cs new file mode 100644 index 0000000..e93f935 --- /dev/null +++ b/RPG/Archer.cs @@ -0,0 +1,63 @@ +using System; + +namespace RPG +{ + public class Archer : Player + { + public Archer() + : base() + { + typeClass = "Лучник"; + skills = new string[] { "Огненные стрелы", "Град стрел", "Мощный выстрел" }; + } + + public override void Skill(out string skillName, out int damage) + { + int probability = random.Next(0, 100); + if (!buff) + { + if (probability <= 20) + { + skillName = "Мощный выстрел"; + } + else if (probability <= 90) + { + skillName = "Огненные стрелы"; + } + else + { + skillName = "Град стрел"; + } + } + else + { + if (probability <= 70) + { + skillName = "Мощный выстрел"; + } + else + { + skillName = "Град стрел"; + } + } + + switch (skillName) + { + case "Мощный выстрел": + damage = (int)(Strength * 1.5); + break; + case "Град стрел": + damage = (int)(Strength * 2.5); + break; + case "Огненные стрелы": + buffName = "Огненные стрелы"; + buff = true; + damage = 0; + break; + default: + damage = 0; + break; + } + } + } +} \ No newline at end of file diff --git a/RPG/Game.cs b/RPG/Game.cs new file mode 100644 index 0000000..62b82b3 --- /dev/null +++ b/RPG/Game.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; + +namespace RPG +{ + public class Game + { + List Players = new List(); + Logger logger = new Logger(); + Random random = new Random(); + Player Player1; + Player Player2; + int counter = 0; + + public void Start(int numOfPlayers) + { + CreatePlayers(numOfPlayers); + while (Players.Count > 1) + { + Fight(); + } + + Console.WriteLine($"\n=========\nПобедитель в игре - {Players[0].typeClass} {Players[0].Name}\n========="); + } + + public void CreatePlayers(int numOfPlayers) + { + + while (numOfPlayers > 0) + { + switch (random.Next(0, 3)) + { + case 0: + Players.Add(new Archer()); + break; + case 1: + Players.Add(new Knight()); + break; + case 2: + Players.Add(new Wizard()); + break; + default: + Players.Add(new Wizard()); + break; + } + + numOfPlayers--; + } + } + + public void Atack(Player Player1, Player Player2) + { + int damage; + + if (Player1.buff) + { + Player1.Atack(out damage); + logger.Atack(Player1, Player2, damage); + Player2.GetDamage(damage + 5); + } + else + { + Player1.Atack(out damage); + logger.Atack(Player1, Player2, damage); + Player2.GetDamage(damage); + } + } + + public void UseSkill(Player Player1, Player Player2) + { + int damage; + string skillName; + + if (Player1.buff) + { + Player1.Skill(out skillName, out damage); + logger.Skill(Player1, Player2, skillName, damage); + Player2.GetDamage(damage + 5); + } + else + { + Player1.Skill(out skillName, out damage); + logger.Skill(Player1, Player2, skillName, damage); + Player2.GetDamage(damage); + } + } + + public void Fight() + { + int i = random.Next(0, Players.Count - 1); + Player1 = Players[i]; + Players.RemoveAt(i); + + i = random.Next(0, Players.Count); + Player2 = Players[i]; + Players.RemoveAt(i); + + int turn = random.Next(0, 1); + counter++; + Console.WriteLine("========="); + Console.WriteLine($"Бой №{counter}"); + + while (true) + { + if (turn == 0) + { + if (Player2.sleepTime == 0) + { + if (random.Next(0, 10) > 6) + { + UseSkill(Player1, Player2); + } + else + { + Atack(Player1, Player2); + } + } + else + { + logger.Sleep(Player1); + Player2.sleepTime--; + } + + if (Player2.Health <= 0) + { + Player1.sleepTime = 0; + Player1.buff = false; + Players.Add(Player1); + logger.Winner(Player1); + logger.Death(Player2); + break; + } + + turn = 1; + } + else + { + if (Player1.sleepTime == 0) + { + if (random.Next(0, 10) > 6) + { + UseSkill(Player2, Player1); + } + else + { + Atack(Player2, Player1); + } + } + else + { + logger.Sleep(Player2); + Player1.sleepTime--; + } + + if (Player1.Health <= 0) + { + Player2.sleepTime = 0; + Player2.buff = false; + Players.Add(Player2); + logger.Winner(Player2); + logger.Death(Player1); + break; + } + + turn = 0; + } + } + } + } +} \ No newline at end of file diff --git a/RPG/Knight.cs b/RPG/Knight.cs new file mode 100644 index 0000000..98b942a --- /dev/null +++ b/RPG/Knight.cs @@ -0,0 +1,48 @@ +using System; + +namespace RPG +{ + public class Knight : Player + { + public Knight() + : base() + { + typeClass = "Рыцарь"; + skills = new string[] { "Удар возмездия", "Удар с размаху", "Раскол земли" }; + } + + public override void Skill(out string skillName, out int damage) + { + int probability = random.Next(0, 100); + if (probability <= 20) + { + skillName = "Удар возмездия"; + } + else if (probability <= 90) + { + skillName = "Удар с размаху"; + } + else + { + skillName = "Раскол земли"; + } + + switch (skillName) + { + case "Удар возмездия": + damage = (int)Math.Floor(Strength * 1.5); + break; + case "Удар с размаху": + damage = (int)Math.Floor(Strength * 1.3); + break; + case "Раскол земли": + sleepTime = 3; + damage = (int)Math.Floor(Strength * 2.5); + break; + default: + damage = 0; + break; + } + } + } +} \ No newline at end of file diff --git a/RPG/Logger.cs b/RPG/Logger.cs new file mode 100644 index 0000000..f1721b3 --- /dev/null +++ b/RPG/Logger.cs @@ -0,0 +1,76 @@ +using System; + +namespace RPG +{ + class Logger + { + public void Atack(Player Player1, Player Player2, int damage) + { + if (Player1.typeClass == "Рыцарь") + { + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) ударил мечом {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) и нанёс {damage} урона."); + } + else if (Player1.typeClass == "Лучник") + { + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) выстрелил в {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) и нанёс {damage} урона."); + } + else + { + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) ударил посохом {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) и нанёс {damage} урона."); + } + + if (Player1.buff) + { + Console.WriteLine($" Дополнительный урон 5 единиц из-за усиления \"{Player1.buffName}\"."); + } + else + { + Console.WriteLine(); + } + } + + public void Skill(Player Player1, Player Player2, string skillName, int damage) + { + if (Player1.sleepTime > 0 && damage == 0) + { + Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) использует умение \"{skillName}\" и оглушает {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) на {Player1.sleepTime} хода."); + } + else if (Player1.sleepTime > 1) + { + Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) использовал(-a) умение \"{skillName}\" и нанес(-ла) {Player2.typeClass} {Player2.Name} {damage} урона. {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) оглушен(-а) на {Player1.sleepTime} ход(-а)."); + } + else if (Player1.buff && damage == 0) + { + Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) активировал усиление \"{skillName}\""); + } + else + { + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) использовал(-a) умение \"{skillName}\" и нанес(-ла) {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) {damage} урона."); + + if (Player1.buff) + { + Console.WriteLine($" Дополнительный урон 5 единиц из-за усиления \"{Player1.buffName}\"."); + } + else + { + Console.WriteLine(); + } + } + } + + public void Sleep(Player Player) + { + Console.WriteLine($"{Player.typeClass} {Player.Name} ({Player.Health} / {Player.maxHealth}) оглушен(-а) и пропускает ход."); + } + + public void Winner(Player Player) + { + Console.WriteLine($"{Player.typeClass} {Player.Name} ({Player.Health} / {Player.maxHealth}) победил(-а)!"); + } + + public void Death(Player Player) + { + Console.WriteLine($"{Player.typeClass} {Player.Name} погибает"); + } + } +} \ No newline at end of file diff --git a/RPG/Player.cs b/RPG/Player.cs new file mode 100644 index 0000000..8ad8868 --- /dev/null +++ b/RPG/Player.cs @@ -0,0 +1,45 @@ +using System; + +namespace RPG +{ + public abstract class Player + { + protected static readonly Random random = new Random(); + public string typeClass; + public string[] skills; + public string skillName; + public bool buff = false; + public string buffName; + public int sleepTime = 0; + public int maxHealth; + public Player() + { + Health = random.Next(50, 100); + maxHealth = Health; + Name = Names[random.Next(0, 9)]; + Strength = random.Next(10, 30); + } + + public static string[] Names = { "Akuma", "Geki", "Retsy", "Balrog", "Vaiper", "Juli", "Set", "Fei Long", "Xokyto", "Ingrid" }; + public string Name { get; protected set; } + public int Strength { get; protected set; } + public int Health { get; set; } + + public virtual void Skill(out string skillName, out int damage) + { + skillName = ""; + damage = 0; + } + + public void Atack(out int damage) + { + damage = random.Next(1, Strength); + } + + public int GetDamage(int damage) + { + Health -= damage; + return Health; + } + } +} diff --git a/RPG/Program.cs b/RPG/Program.cs new file mode 100644 index 0000000..d3fcea7 --- /dev/null +++ b/RPG/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace RPG +{ + class Program + { + static void Main(string[] args) + { + Game game = new Game(); + Console.Write("Введите число игроков: "); + + int numOfPlayers = Int32.Parse(Console.ReadLine()); + + if (numOfPlayers % 2 != 0) + { + numOfPlayers += 1; + } + + game.Start(numOfPlayers); + + Console.ReadKey(); + } + } +} \ No newline at end of file diff --git a/RPG/RPG.csproj b/RPG/RPG.csproj new file mode 100644 index 0000000..0a40805 --- /dev/null +++ b/RPG/RPG.csproj @@ -0,0 +1,10 @@ + + + + Exe + netcoreapp3.0 + True + 1573,1591,1701;1702;1705; + + + diff --git a/RPG/Wizard.cs b/RPG/Wizard.cs new file mode 100644 index 0000000..60c138a --- /dev/null +++ b/RPG/Wizard.cs @@ -0,0 +1,41 @@ +using System; + +namespace RPG +{ + public class Wizard : Player + { + public Wizard() + : base() + { + typeClass = "Маг"; + skills = new string[] { "Заворожение", "Метеор" }; + } + + public override void Skill(out string skillName, out int damage) + { + int probability = random.Next(0, 100); + if (probability <= 60 && sleepTime == 0) + { + skillName = "Заворожение"; + } + else + { + skillName = "Метеор"; + } + + switch (skillName) + { + case "Заворожение": + sleepTime = 2; + damage = 0; + break; + case "Метеор": + damage = (int)Math.Floor(Strength * 2.5); + break; + default: + damage = 0; + break; + } + } + } +} \ No newline at end of file diff --git a/courseworkspace.code-workspace b/courseworkspace.code-workspace index 4f9af01..19f3c44 100644 --- a/courseworkspace.code-workspace +++ b/courseworkspace.code-workspace @@ -1,11 +1,17 @@ { - "folders": [ - { - "path": "CourseApp" - }, - { - "path": "CourseApp.Tests" - } - ], - "settings": {} -} \ No newline at end of file + "folders": [ + { + "path": "CourseApp" + }, + { + "path": "CourseApp.Tests" + }, + { + "path": "RPG" + }, + { + "path": "RPG.Tests" + } + ], + "settings": {} +} From 65596223356b906cbb19b3b29d6d8e2e63108a50 Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 01:05:06 +0300 Subject: [PATCH 3/9] RPG v1.01 --- RPG/Archer.cs | 14 +++++++------- RPG/Game.cs | 8 ++++---- RPG/Knight.cs | 10 +++++----- RPG/Logger.cs | 18 +++++++++--------- RPG/Player.cs | 6 +++++- RPG/Wizard.cs | 6 +++--- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/RPG/Archer.cs b/RPG/Archer.cs index e93f935..e91ea39 100644 --- a/RPG/Archer.cs +++ b/RPG/Archer.cs @@ -8,7 +8,7 @@ public Archer() : base() { typeClass = "Лучник"; - skills = new string[] { "Огненные стрелы", "Град стрел", "Мощный выстрел" }; + skills = new string[] { "Огненные стрелы", "Шквал стрел", "Стрела правосудия" }; } public override void Skill(out string skillName, out int damage) @@ -18,7 +18,7 @@ public override void Skill(out string skillName, out int damage) { if (probability <= 20) { - skillName = "Мощный выстрел"; + skillName = "Стрела правосудия"; } else if (probability <= 90) { @@ -26,27 +26,27 @@ public override void Skill(out string skillName, out int damage) } else { - skillName = "Град стрел"; + skillName = "Шквал стрел"; } } else { if (probability <= 70) { - skillName = "Мощный выстрел"; + skillName = "Стрела правосудия"; } else { - skillName = "Град стрел"; + skillName = "Шквал стрел"; } } switch (skillName) { - case "Мощный выстрел": + case "Стрела правосудия": damage = (int)(Strength * 1.5); break; - case "Град стрел": + case "Шквал стрел": damage = (int)(Strength * 2.5); break; case "Огненные стрелы": diff --git a/RPG/Game.cs b/RPG/Game.cs index 62b82b3..073c4ed 100644 --- a/RPG/Game.cs +++ b/RPG/Game.cs @@ -20,12 +20,11 @@ public void Start(int numOfPlayers) Fight(); } - Console.WriteLine($"\n=========\nПобедитель в игре - {Players[0].typeClass} {Players[0].Name}\n========="); + Console.WriteLine($"\nПобедитель: {Players[0].typeClass} {Players[0].Name}\n"); } public void CreatePlayers(int numOfPlayers) { - while (numOfPlayers > 0) { switch (random.Next(0, 3)) @@ -97,8 +96,9 @@ public void Fight() int turn = random.Next(0, 1); counter++; - Console.WriteLine("========="); - Console.WriteLine($"Бой №{counter}"); + Console.WriteLine("\n"); + Console.WriteLine($"{counter} бой"); + Console.WriteLine("\n"); while (true) { diff --git a/RPG/Knight.cs b/RPG/Knight.cs index 98b942a..2906156 100644 --- a/RPG/Knight.cs +++ b/RPG/Knight.cs @@ -8,7 +8,7 @@ public Knight() : base() { typeClass = "Рыцарь"; - skills = new string[] { "Удар возмездия", "Удар с размаху", "Раскол земли" }; + skills = new string[] { "Удар возмездия", "Буря клинков", "Удар смерти" }; } public override void Skill(out string skillName, out int damage) @@ -20,11 +20,11 @@ public override void Skill(out string skillName, out int damage) } else if (probability <= 90) { - skillName = "Удар с размаху"; + skillName = "Буря клинков"; } else { - skillName = "Раскол земли"; + skillName = "Удар смерти"; } switch (skillName) @@ -32,10 +32,10 @@ public override void Skill(out string skillName, out int damage) case "Удар возмездия": damage = (int)Math.Floor(Strength * 1.5); break; - case "Удар с размаху": + case "Буря клинков": damage = (int)Math.Floor(Strength * 1.3); break; - case "Раскол земли": + case "Удар смерти": sleepTime = 3; damage = (int)Math.Floor(Strength * 2.5); break; diff --git a/RPG/Logger.cs b/RPG/Logger.cs index f1721b3..90020f8 100644 --- a/RPG/Logger.cs +++ b/RPG/Logger.cs @@ -8,15 +8,15 @@ public void Atack(Player Player1, Player Player2, int damage) { if (Player1.typeClass == "Рыцарь") { - Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) ударил мечом {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) и нанёс {damage} урона."); + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) ударил мечом {Player2.typeClass} {Player2.Name} ({Player2.Health} из {Player2.maxHealth} hp) и нанёс {damage} урона."); } else if (Player1.typeClass == "Лучник") { - Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) выстрелил в {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) и нанёс {damage} урона."); + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) выстрелил в {Player2.typeClass} {Player2.Name} ({Player2.Health} из {Player2.maxHealth} hp) и нанёс {damage} урона."); } else { - Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) ударил посохом {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) и нанёс {damage} урона."); + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) ударил посохом {Player2.typeClass} {Player2.Name} ({Player2.Health} из {Player2.maxHealth} hp) и нанёс {damage} урона."); } if (Player1.buff) @@ -33,19 +33,19 @@ public void Skill(Player Player1, Player Player2, string skillName, int damage) { if (Player1.sleepTime > 0 && damage == 0) { - Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) использует умение \"{skillName}\" и оглушает {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) на {Player1.sleepTime} хода."); + Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) использует умение \"{skillName}\" и оглушает {Player2.typeClass} {Player2.Name} ({Player2.Health} из {Player2.maxHealth} hp) на {Player1.sleepTime} хода."); } else if (Player1.sleepTime > 1) { - Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) использовал(-a) умение \"{skillName}\" и нанес(-ла) {Player2.typeClass} {Player2.Name} {damage} урона. {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) оглушен(-а) на {Player1.sleepTime} ход(-а)."); + Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) использовал(-a) умение \"{skillName}\" и нанес(-ла) {Player2.typeClass} {Player2.Name} {damage} урона. {Player2.typeClass} {Player2.Name} ({Player2.Health} из {Player2.maxHealth} hp) оглушен(-а) на {Player1.sleepTime} ход(-а)."); } else if (Player1.buff && damage == 0) { - Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) активировал усиление \"{skillName}\""); + Console.WriteLine($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) активировал усиление \"{skillName}\""); } else { - Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} / {Player1.maxHealth}) использовал(-a) умение \"{skillName}\" и нанес(-ла) {Player2.typeClass} {Player2.Name} ({Player2.Health} / {Player2.maxHealth}) {damage} урона."); + Console.Write($"{Player1.typeClass} {Player1.Name} ({Player1.Health} из {Player1.maxHealth} hp) использовал(-a) умение \"{skillName}\" и нанес(-ла) {Player2.typeClass} {Player2.Name} ({Player2.Health} из {Player2.maxHealth} hp) {damage} урона."); if (Player1.buff) { @@ -60,12 +60,12 @@ public void Skill(Player Player1, Player Player2, string skillName, int damage) public void Sleep(Player Player) { - Console.WriteLine($"{Player.typeClass} {Player.Name} ({Player.Health} / {Player.maxHealth}) оглушен(-а) и пропускает ход."); + Console.WriteLine($"{Player.typeClass} {Player.Name} ({Player.Health} из {Player.maxHealth} hp) оглушен(-а) и пропускает ход."); } public void Winner(Player Player) { - Console.WriteLine($"{Player.typeClass} {Player.Name} ({Player.Health} / {Player.maxHealth}) победил(-а)!"); + Console.WriteLine($"{Player.typeClass} {Player.Name} ({Player.Health} из {Player.maxHealth} hp) победил(-а)!"); } public void Death(Player Player) diff --git a/RPG/Player.cs b/RPG/Player.cs index 8ad8868..c9223be 100644 --- a/RPG/Player.cs +++ b/RPG/Player.cs @@ -4,7 +4,6 @@ namespace RPG { public abstract class Player { - protected static readonly Random random = new Random(); public string typeClass; public string[] skills; public string skillName; @@ -12,6 +11,8 @@ public abstract class Player public string buffName; public int sleepTime = 0; public int maxHealth; + protected static readonly Random random = new Random(); + public Player() { Health = random.Next(50, 100); @@ -21,8 +22,11 @@ public Player() } public static string[] Names = { "Akuma", "Geki", "Retsy", "Balrog", "Vaiper", "Juli", "Set", "Fei Long", "Xokyto", "Ingrid" }; + public string Name { get; protected set; } + public int Strength { get; protected set; } + public int Health { get; set; } public virtual void Skill(out string skillName, out int damage) diff --git a/RPG/Wizard.cs b/RPG/Wizard.cs index 60c138a..feee86c 100644 --- a/RPG/Wizard.cs +++ b/RPG/Wizard.cs @@ -8,7 +8,7 @@ public Wizard() : base() { typeClass = "Маг"; - skills = new string[] { "Заворожение", "Метеор" }; + skills = new string[] { "Заворожение", "Огненный шар" }; } public override void Skill(out string skillName, out int damage) @@ -20,7 +20,7 @@ public override void Skill(out string skillName, out int damage) } else { - skillName = "Метеор"; + skillName = "Огненный шар"; } switch (skillName) @@ -29,7 +29,7 @@ public override void Skill(out string skillName, out int damage) sleepTime = 2; damage = 0; break; - case "Метеор": + case "Огненный шар": damage = (int)Math.Floor(Strength * 2.5); break; default: From a672ca90e9f90c585c860a08c32f530a7d70e1aa Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 15:04:03 +0300 Subject: [PATCH 4/9] RPG 1.02 fix startupobject --- CourseApp/Program.cs | 13 ------------- RPG.Tests/RPGTests.cs | 6 +++--- RPG/Prog.cs | 23 +++++++++++++++++++++++ RPG/RPG.csproj | 4 ++++ courseworkspace.code-workspace | 4 ++++ 5 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 RPG/Prog.cs diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 8ba6b4d..d654c2e 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -6,19 +6,6 @@ public class Program { public static void Main(string[] args) { - Game game = new Game(); - Console.Write("Введите число героев: "); - - int numOfHeroes = Int32.Parse(Console.ReadLine()); - - if(numOfHeroes % 2 != 0) - { - numOfHeroes += 1; - } - - game.Start(numOfHeroes); - - Console.ReadKey(); } } } diff --git a/RPG.Tests/RPGTests.cs b/RPG.Tests/RPGTests.cs index d63c920..92884bb 100644 --- a/RPG.Tests/RPGTests.cs +++ b/RPG.Tests/RPGTests.cs @@ -29,7 +29,7 @@ public void KnightSkillsTest() knight.Skill(out skillName, out damage); - if ((skillName == "Удар возмездия" || skillName == "Удар с размаху" || skillName == "Раскол земли") && damage > 0) + if ((skillName == "Удар возмездия" || skillName == "Буря клинков" || skillName == "Удар смерти") && damage > 0) { Assert.True(true); } @@ -49,7 +49,7 @@ public void ArcherSkillsTest() { Assert.True(true); } - else if ((skillName == "Мощный выстрел" || skillName == "Град стрел") && damage > 0) + else if ((skillName == "Стрела правосудия" || skillName == "Шквал стрел") && damage > 0) { Assert.True(true); } @@ -69,7 +69,7 @@ public void WizardSkillsTest() { Assert.True(true); } - else if (skillName == "Метеор" && damage > 0) + else if (skillName == "Огненный шар" && damage > 0) { Assert.True(true); } diff --git a/RPG/Prog.cs b/RPG/Prog.cs new file mode 100644 index 0000000..5502b6e --- /dev/null +++ b/RPG/Prog.cs @@ -0,0 +1,23 @@ +using System; +namespace RPG +{ + public class Prog + { + public static void Main(string[] args) + { + Game game = new Game(); + Console.Write("Введите число героев: "); + + int numOfHeroes = Int32.Parse(Console.ReadLine()); + + if (numOfHeroes % 2 != 0) + { + numOfHeroes += 1; + } + + game.Start(numOfHeroes); + + Console.ReadKey(); + } + } +} \ No newline at end of file diff --git a/RPG/RPG.csproj b/RPG/RPG.csproj index 0a40805..7f29fcb 100644 --- a/RPG/RPG.csproj +++ b/RPG/RPG.csproj @@ -7,4 +7,8 @@ 1573,1591,1701;1702;1705; + + RPG.Prog + + diff --git a/courseworkspace.code-workspace b/courseworkspace.code-workspace index 19f3c44..fa5ec1d 100644 --- a/courseworkspace.code-workspace +++ b/courseworkspace.code-workspace @@ -1,15 +1,19 @@ { "folders": [ { + "name": "CourseApp", "path": "CourseApp" }, { + "name": "CourseApp.Tests", "path": "CourseApp.Tests" }, { + "name": "RPG", "path": "RPG" }, { + "name": "RPG.Tests", "path": "RPG.Tests" } ], From 4db51fee38424981245dfcfdf46a3492c8f249e6 Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 15:16:28 +0300 Subject: [PATCH 5/9] 123 --- RPG/Game.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RPG/Game.cs b/RPG/Game.cs index 073c4ed..bbe7189 100644 --- a/RPG/Game.cs +++ b/RPG/Game.cs @@ -96,9 +96,9 @@ public void Fight() int turn = random.Next(0, 1); counter++; - Console.WriteLine("\n"); + Console.WriteLine("\n////////////"); Console.WriteLine($"{counter} бой"); - Console.WriteLine("\n"); + Console.WriteLine("////////////\n"); while (true) { From cfbc2ae83fe1e6b09394b7fc3c630490c3f94f81 Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 15:19:20 +0300 Subject: [PATCH 6/9] 1234 --- RPG/Game.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RPG/Game.cs b/RPG/Game.cs index bbe7189..d5efdd3 100644 --- a/RPG/Game.cs +++ b/RPG/Game.cs @@ -96,9 +96,9 @@ public void Fight() int turn = random.Next(0, 1); counter++; - Console.WriteLine("\n////////////"); + Console.WriteLine("\n/////////////"); Console.WriteLine($"{counter} бой"); - Console.WriteLine("////////////\n"); + Console.WriteLine("/////////////\n"); while (true) { From 4f25cf661d16c1ff1ecb06e8f81fe4a1758b2d04 Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 15:23:17 +0300 Subject: [PATCH 7/9] lalala --- CourseApp/Program.cs | 63 -------------------------------------------- 1 file changed, 63 deletions(-) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 9d17d43..03d3ca1 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -7,69 +7,6 @@ public class Program { public static void Main(string[] args) { - public static double Formula(double a, double x) - { - var y = Math.Pow(a, Math.Pow(x, 2) - 1) - Math.Log10(Math.Pow(x, 2) - 1) + Math.Pow(Math.Sqrt(Math.Pow(x, 2) - 1), 1 / 3); - return y; - } - - public static List TaskA(double a, double xn, double xk, double dx) - { - if (xk < xn) - { - return new List(); - } - else - { - List y = new List((int)((xk - xn) / dx)); - for (double x = xn; x < xk; x += dx) - { - y.Add(Formula(a, x)); - } - - return y; - } - } - - public static List TaskB(double a, List x) - { - List y = new List(); - for (var i = 0; i < x.Count; i++) - { - y.Add(Formula(a, x[i])); - } - - return y; - } - - public static void Main(string[] args) - { - const double a = 1.6; - const double xn = 1.2; - const double xk = 3.7; - const double dx = 0.5; - Console.WriteLine("Task А:"); - foreach (var item in TaskA(a, xn, xk, dx)) - { - Console.WriteLine($"y = {item}"); - } - - Console.WriteLine("Task B:"); - List x = new List { 1.28, 1.36, 2.47, 3.68, 4.56 }; - foreach (var item in TaskB(a, x)) - { - Console.WriteLine($"y = {item}"); - } - - Person[] people = new Person[2]; - people[0] = new Person("Sasha", "Smirnov", 25); - people[1] = new Person("Polina", "Suvorova", 22); - foreach (var item in people) - { - Console.WriteLine(item); - } - - Console.ReadLine(); } } } From 40cbdfbaf24d0526acb85bcd02d4d803dd1aa6bd Mon Sep 17 00:00:00 2001 From: Viktor Morohovsev <171007030408fbd@gmail.com> Date: Wed, 8 Jan 2020 15:30:03 +0300 Subject: [PATCH 8/9] delete --- CourseApp.Tests/DemoTest.cs | 40 ------------------ CourseApp.Tests/PersonTest.cs | 78 ----------------------------------- CourseApp/Person.cs | 61 --------------------------- 3 files changed, 179 deletions(-) delete mode 100644 CourseApp.Tests/PersonTest.cs delete mode 100644 CourseApp/Person.cs diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index 52c0aa3..4de869e 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -12,45 +12,5 @@ public void Test1() Assert.True(true); } - [Fact] - public void TestMyFunctionZeros() - { - var res = Program.Formula(0.0, 0.0); - Assert.Equal(double.NaN, res); - } - - [Fact] - public void TestTaskB() - { - List x = new List { 1.84, 4.05, 3.67, 2.18, 1.17 }; - List res = Program.TaskB(1.6, x); - List expy = new List { 3.691061372588238, 1392.8345934281351, 350.7785466064311, 6.25933353327923, 2.622414465082322 }; - for (int i = 0; i < 5; i++) - { - Assert.Equal(expy[i], res[i], 3); - } - } - - [Fact] - public void TestTaskA() - { - double a = 1.6; - double xn = 1.2; - double xk = 3.7; - double dx = 0.5; - List res = Program.TaskA(a, xn, xk, dx); - List expy = new List { 2.58628588710697, 3.15454831838707, 6.49450906742811, 19.428489457705, 76.9595290357977 }; - for (int i = 0; i < 5; i++) - { - Assert.Equal(expy[i], res[i], 3); - } - } - - [Fact] - public void XnMoreThanXkAndUncorrectDx() - { - List res = Program.TaskA(1.6, 3.7, 1.2, 0.7); - Assert.Equal(res, new List()); - } } } diff --git a/CourseApp.Tests/PersonTest.cs b/CourseApp.Tests/PersonTest.cs deleted file mode 100644 index bc89213..0000000 --- a/CourseApp.Tests/PersonTest.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Xunit; - -namespace CourseApp.Tests -{ - public class PersonTest - { - [Fact] - public void TestConstructor() - { - var item = new Person(); - Assert.Equal(18, item.Age); - Assert.Equal("Name", item.Name); - Assert.Equal("LastName", item.LastName); - } - - [Fact] - public void TestSetAge() - { - var item = new Person(); - item.Age = 30; - Assert.Equal(30, item.Age); - } - - [Fact] - public void TestIncorrectSetAge() - { - try - { - var item = new Person(); - item.Age = -1000; - } - catch (System.Exception) - { - Console.WriteLine("Age should be more 0 and less than 100"); - Assert.True(true); - } - } - - [Fact] - public void TestCorrectIncorrectSetAge() - { - var item = new Person(); - item.Age = 27; - try - { - item.Age = -1; - } - catch - { - Assert.Equal(27, item.Age); - return; - } - - Assert.Equal(27, item.Age); - } - - [Fact] - public void TestIncorrectSetString() - { - var item = new Person(); - item.Name = string.Empty; - item.LastName = string.Empty; - Assert.Equal(string.Empty, item.Name); - Assert.Equal(string.Empty, item.LastName); - } - - [Fact] - public void TestCorrectSetString() - { - var item = new Person(); - item.Name = "VikiVik"; - item.LastName = "Moro"; - Assert.Equal("VikiVik", item.Name); - Assert.Equal("Moro", item.LastName); - } - } -} diff --git a/CourseApp/Person.cs b/CourseApp/Person.cs deleted file mode 100644 index e069e53..0000000 --- a/CourseApp/Person.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; - -namespace CourseApp -{ - public class Person - { - private int age; - - public Person() - : this("Name") - { - } - - public Person(string name) - : this(name, "LastName") - { - } - - public Person(string name, string lastname) - : this(name, lastname, 18) - { - } - - public Person(string name, string lastname, int age) - { - this.Name = name; - this.LastName = lastname; - this.age = age; - } - - public int Age - { - get - { - return this.age; - } - - set - { - if (value >= 0 && value < 100) - { - this.age = value; - } - else - { - throw new System.Exception("Age should be more 0 and less than 100"); - } - } - } - - public string Name { get; set; } - - public string LastName { get; set; } - - public override string ToString() - { - string s = $"Hi. I am {Name} {LastName}. I am {Age} years old."; - return s; - } - } -} \ No newline at end of file From bedc3277df13632c6a795ff1bb05fd721b5c4136 Mon Sep 17 00:00:00 2001 From: DressCodeBoy <52357422+DressCodeBoy@users.noreply.github.com> Date: Wed, 8 Jan 2020 15:36:31 +0300 Subject: [PATCH 9/9] Update DemoTest.cs --- CourseApp.Tests/DemoTest.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index 4de869e..157a469 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -11,6 +11,5 @@ public void Test1() { Assert.True(true); } - } }