-
Notifications
You must be signed in to change notification settings - Fork 24
Kochneva darina alekseevna #19
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
Open
CuteDarKy
wants to merge
11
commits into
ISUCT:Kochneva_Darina_Alekseevna
Choose a base branch
from
CuteDarKy:Kochneva_Darina_Alekseevna
base: Kochneva_Darina_Alekseevna
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bb72f75
Кочнева Дарина 2/42 Классы
CuteDarKy c2666de
Кочнева Дарина 2/42 Тесты к классам
CuteDarKy c5ec321
Дочерние классы и тесты к ним
CuteDarKy 52bebfc
Tests
CuteDarKy e83d0a0
rpg
CuteDarKy 63e3be2
Update Game.cs
CuteDarKy 1f27b77
Update Player.cs
CuteDarKy 68d763d
Update Wizard.cs
CuteDarKy ea0d15f
Update Paladin.cs
CuteDarKy fdb657f
Update Archer.cs
CuteDarKy dcd2309
Update Logger.cs
CuteDarKy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
namespace CourseApp.Tests | ||
{ | ||
using Xunit; | ||
|
||
public class CountryTest | ||
{ | ||
[Fact] | ||
public void RussiaTest() | ||
{ | ||
var rus = new Russia("Russia", "Moscow", 17000); | ||
Assert.Equal("Russia", rus.Name); | ||
Assert.Equal("Moscow", rus.Capital); | ||
Assert.Equal(17000, rus.Square); | ||
} | ||
|
||
[Fact] | ||
public void CanadaTest() | ||
{ | ||
var can = new Canada("Canada", "Ottawa", 10000); | ||
Assert.Equal("Canada", can.Name); | ||
Assert.Equal("Ottawa", can.Capital); | ||
Assert.Equal(10000, can.Square); | ||
} | ||
|
||
[Fact] | ||
public void USATest() | ||
{ | ||
var usa = new USA("USA", "Washington", 7000); | ||
Assert.Equal("USA", usa.Name); | ||
Assert.Equal("Washington", usa.Capital); | ||
Assert.Equal(7000, usa.Square); | ||
} | ||
|
||
[Fact] | ||
public void RussiaCountryAgeTest() | ||
{ | ||
var rus = new Russia("Russia", "Moscow", 17000); | ||
var result = rus.CountryAge(); | ||
Assert.Equal("1159 years ", result); | ||
} | ||
|
||
[Fact] | ||
public void CanadaCountryAgeTest() | ||
{ | ||
var can = new Canada("Canada", "Ottawa", 10000); | ||
var result = can.CountryAge(); | ||
Assert.Equal("155 years ", result); | ||
} | ||
|
||
[Fact] | ||
public void USACountryAgeTest() | ||
{ | ||
var usa = new USA("USA", "Washington", 7000); | ||
var result = usa.CountryAge(); | ||
Assert.Equal("245 years ", result); | ||
} | ||
|
||
[Fact] | ||
public void RussiaPresidentsNameTest() | ||
{ | ||
var rus = new Russia("Russia", "Moscow", 17000); | ||
var result = rus.PresidentsName(); | ||
Assert.Equal("Putin ", result); | ||
} | ||
|
||
[Fact] | ||
public void CanadaPresidentsNameTest() | ||
{ | ||
var can = new Canada("Canada", "Ottawa", 10000); | ||
var result = can.PresidentsName(); | ||
Assert.Equal("Carl ", result); | ||
} | ||
|
||
[Fact] | ||
public void USAPresidentsNameTest() | ||
{ | ||
var usa = new USA("USA", "Washington", 7000); | ||
var result = usa.PresidentsName(); | ||
Assert.Equal("Biden ", result); | ||
} | ||
|
||
[Fact] | ||
public void RussiaNameOfElementTest() | ||
{ | ||
var rus = new Russia("Russia", "Moscow", 17000); | ||
var result = rus.NameOfElement(); | ||
Assert.Equal("Russia: ", result); | ||
} | ||
|
||
[Fact] | ||
public void CanadaNameOfElementTest() | ||
{ | ||
var can = new Canada("Canada", "Ottawa", 10000); | ||
var result = can.NameOfElement(); | ||
Assert.Equal("Canada: ", result); | ||
} | ||
|
||
[Fact] | ||
public void USANameOfElementTest() | ||
{ | ||
var usa = new USA("USA", "Washington", 7000); | ||
var result = usa.NameOfElement(); | ||
Assert.Equal("USA: ", result); | ||
} | ||
|
||
[Fact] | ||
public void RussiaToStringTest() | ||
{ | ||
var rus = new Russia("Russia", "Moscow", 17000); | ||
var result = rus.ToString(); | ||
Assert.Equal("Moscow is a capital of Russia", result); | ||
} | ||
|
||
[Fact] | ||
public void CanadaToStringTest() | ||
{ | ||
var can = new Canada("Canada", "Ottawa", 10000); | ||
var result = can.ToString(); | ||
Assert.Equal("Ottawa is a capital of Canada", result); | ||
} | ||
|
||
[Fact] | ||
public void USANameToStringTest() | ||
{ | ||
var usa = new USA("USA", "Washington", 7000); | ||
var result = usa.ToString(); | ||
Assert.Equal("Washington is a capital of USA", result); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace CourseApp; | ||
|
||
using System; | ||
|
||
public class Canada : Country | ||
{ | ||
public Canada(string name, string capital, double sq) | ||
: base(name, capital, sq) | ||
{ | ||
} | ||
|
||
public override string CountryAge() | ||
{ | ||
return "155 years "; | ||
} | ||
|
||
public override string PresidentsName() | ||
{ | ||
return "Carl "; | ||
} | ||
|
||
public override string NameOfElement() | ||
{ | ||
return "Canada: "; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"{Capital} is a capital of {Name}"; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace CourseApp; | ||
|
||
using System; | ||
|
||
public abstract class Country | ||
{ | ||
private double square; | ||
|
||
public Country(string name, string capital, double sq) | ||
{ | ||
this.Name = name; | ||
this.Capital = capital; | ||
this.Square = sq; | ||
} | ||
|
||
public string Name { get; set; } | ||
|
||
public string Capital { get; set; } | ||
|
||
public double Square | ||
{ | ||
get | ||
{ | ||
return square; | ||
} | ||
|
||
set | ||
{ | ||
square = value; | ||
} | ||
} | ||
|
||
public void Print() | ||
{ | ||
Console.Write($"Название: {Name} Столица: {Capital} Площадь: {Square} км^2 "); | ||
} | ||
|
||
public virtual string CountryAge() | ||
{ | ||
return "2000 years"; | ||
} | ||
|
||
public virtual string PresidentsName() | ||
{ | ||
return "sss"; | ||
} | ||
|
||
public virtual string NameOfElement() | ||
{ | ||
return "3"; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
namespace CourseApp | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello World"); | ||
Game.Start(); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace CourseApp.RPGsaga; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class Archer : Player | ||
{ | ||
public Archer(int health, int force, string name, string abilityName) | ||
: base(health, force, name, "Огненные стрелы") | ||
{ | ||
} | ||
|
||
public bool AbilityUse = false; | ||
|
||
public override string ToString() | ||
{ | ||
return "(Лучник) " + Name; | ||
} | ||
|
||
public override int Ability(string AbilityUse) | ||
{ | ||
Random rnd = new Random(); | ||
int prob = (int)rnd.NextInt64(1, 10); | ||
switch (prob) | ||
{ | ||
case 1: | ||
return AbilityUse = true; | ||
default: | ||
return AbilityUse = false; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
namespace CourseApp.RPGsaga; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
public class Game | ||
{ | ||
public void Play() | ||
{ | ||
EnterNumberOfPlayers(); | ||
List<Player> playerList = PlayerListGenerator(players); | ||
List<Player> winnerList = new List<Player>(); | ||
Player winner = new Player(); | ||
Logger.Winner(Round(List<Player> playerList)); | ||
} | ||
|
||
private static void Round(List<Player> playerList) | ||
{ | ||
for (int i = 0; i < playerList.Count / 2; i++) | ||
{ | ||
if (playerList.Count == null) | ||
{ | ||
break; | ||
} | ||
Logger.Round(i); | ||
Player[] Members = { playerList[i * 2], playerList[(i * 2) + 1] }; | ||
Logger.VS(Player[] Members); | ||
winnerList.Add(Figth(Members)); | ||
} | ||
for (int i = 1; i < playerList.Count; i++) | ||
{ | ||
playerList.RemoveAt(i); | ||
} | ||
for (int i = 0; i < winnerList.Count / 2; i++) | ||
{ | ||
if (winerList.Count == 1) | ||
{ | ||
return winner = winerList[i * 2]; | ||
break; | ||
} | ||
Logger.Round(i); | ||
Player[] Members = { winnerList[i * 2], winnerList[(i * 2) + 1] }; | ||
Logger.VS(Player[] Members); | ||
winnerList.Add(Figth(Members)); | ||
} | ||
for (int i = 1; i < winnerList.Count-1; i++) | ||
{ | ||
winnerList.RemoveAt(i); | ||
} | ||
} | ||
|
||
private static Fight(Player[] Members) | ||
{ | ||
for (int i = 0; ; i++) | ||
{ | ||
|
||
Members[(i * 2) + 1].NewHealth(Members[i * 2].Damage()); | ||
Logger.Figth(Members[i * 2].Damage()); | ||
if (Members[(i * 2) + 1].Death()) | ||
{ | ||
Logger.Death(Player[] Members); | ||
return Members[i * 2]; | ||
break; | ||
} | ||
else | ||
{ | ||
swap = Members[i * 2]; | ||
Members[(i * 2) + 1] = Members[i * 2]; | ||
Members[i * 2] = swap; | ||
} | ||
} | ||
} | ||
|
||
private static List<Player> PlayerListGenerator(int counter) | ||
{ | ||
List<Player> playerList = new List<Player>(); | ||
for (int i = 0; i < counter; i++) | ||
{ | ||
Random rnd = new Random(); | ||
int health = (int)rnd.NextInt64(1, 100); | ||
int force = (int)rnd.NextInt64(1, 100); | ||
int chouse = (int)rnd.NextInt64(0, 3); | ||
string[] names = { "Даламар", "Володар", "Геральд", "Вельгеброрд", "Глэстин", "Винхелт", "Грендольф", "Рэйкон", "Шапалаум", "Зорро", "Кьярос", "Йотенхел", "Кузко" }; | ||
playerList.Add(PlayerGenerator(health, force, chouse, names[rnd.Next(names.Length)); | ||
} | ||
|
||
return playerList; | ||
} | ||
|
||
private static Player PlayerGenerator(int health, int forceb, int chouse, string name) | ||
{ | ||
switch (chouse) | ||
{ | ||
case 0: | ||
return new Paladin(health, force, name); | ||
case 1: | ||
return new Wizard(health, force, name); | ||
case 2: | ||
return new Archer(health, force, name); | ||
default: | ||
return new Paladin(health, force, name); | ||
} | ||
} | ||
|
||
private void EnterNumberOfPlayers() | ||
{ | ||
Console.WriteLine("Введите количество игроков (число должно быть чётным):"); | ||
int players = Convert.ToInt32(Console.ReadLine()); | ||
if (players <= 1) | ||
{ | ||
Console.WriteLine("Число игроков не может быть меньше 2"); | ||
} | ||
else if (players % 2 != 0) | ||
{ | ||
Console.WriteLine("Число игроков должно быть чётным"); | ||
} | ||
} | ||
public int Summa(int a, int b) | ||
{ | ||
return a+b; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
часть тут можно сократить на inlineData