-
Notifications
You must be signed in to change notification settings - Fork 38
Nikita rybkin #35
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
base: Nikita_Rybkin
Are you sure you want to change the base?
Nikita rybkin #35
Changes from all commits
4710eea
a5111a5
bfbc072
d0373ba
93ffe50
ba9e064
46a0213
18a3d9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| namespace CourseApp.Tests | ||
| { | ||
| using Xunit; | ||
|
|
||
| public class AnimalsTest | ||
| { | ||
| [Theory] | ||
| [InlineData("Animals", "Animals")] | ||
| [InlineData("Бычок", "Бычок")] | ||
| public void TestName(string a, string exp) | ||
| { | ||
| Pig actualResult = new Pig(a, 1); | ||
| Assert.Equal(exp, actualResult.Name); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(88, 88)] | ||
| [InlineData(-20, 0)] | ||
| public void TestWeight(int a, int exp) | ||
| { | ||
| Pig actual = new Pig(" ", a); | ||
| Assert.Equal(exp, actual.Weight); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(0, 0)] | ||
| [InlineData(-1, 0)] | ||
| [InlineData(88, 88)] | ||
| public void TestFat(int a, int expected) | ||
| { | ||
| Pig actual = new Pig(" ", 0, a); | ||
| Assert.Equal(expected, actual.Lard); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(0, 0)] | ||
| [InlineData(-1, 0)] | ||
| [InlineData(8, 8)] | ||
| public void TestAge(int a, int expected) | ||
| { | ||
| Pig actual = new Pig(" ", 0, a, 88); | ||
| Assert.Equal(expected, actual.Age); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData("Бычок", 5, "Из Бычок можно получить 5 сала\n")] | ||
| [InlineData("Бычок", 0, "Бычок Без сала\n")] | ||
| public void TestToString(string n, int a, string expected) | ||
| { | ||
| Bull actual = new Bull(n, 8, a); | ||
| Assert.Equal(expected, actual.ToString()); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| namespace CourseApp.Tests | ||
| { | ||
| using Xunit; | ||
|
|
||
| public class MyProgTests | ||
| { | ||
| [Fact] | ||
| public void Sum1_And2_Returned3() | ||
| { | ||
| int x = 1; | ||
| int y = 2; | ||
| int expected = 3; | ||
|
|
||
| MyProg c = new MyProg(); | ||
| int actual = c.Sum(x, y); | ||
|
|
||
| Assert.Equal(expected, actual); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| namespace CourseApp | ||
| { | ||
| /* using System; */ | ||
| /* using System.Collections.Generic;*/ | ||
|
|
||
| public abstract class Animals | ||
| { | ||
| private int lard; | ||
| private int weight; | ||
| private int age; | ||
|
|
||
| public Animals() | ||
| : this("неизвестного животного", 10, 12, 13) | ||
| { | ||
| } | ||
|
|
||
| public Animals(string name, int weight) | ||
| : this(name, weight, 0, 0) | ||
| { | ||
| } | ||
|
|
||
| public Animals(string name, int weight, int lard) | ||
| : this(name, weight, 0, lard) | ||
| { | ||
| } | ||
|
|
||
| public Animals(string name, int weight, int age, int lard) | ||
| { | ||
| Name = name; | ||
| Lard = lard; | ||
| Age = age; | ||
| Weight = weight; | ||
| } | ||
|
Comment on lines
+12
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need that much of constructors? |
||
|
|
||
| public string Name | ||
| { | ||
| get; | ||
| set; | ||
| } | ||
|
|
||
| public int Weight | ||
| { | ||
| get | ||
| { | ||
| return weight; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| if (value < 0) | ||
| { | ||
| weight = 0; | ||
| } | ||
| else | ||
| { | ||
| weight = value; | ||
| } | ||
|
Comment on lines
+50
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's throw exception here |
||
| } | ||
| } | ||
|
|
||
| public int Age | ||
| { | ||
| get | ||
| { | ||
| return age; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| if (value < 0) | ||
| { | ||
| age = 0; | ||
| } | ||
| else | ||
| { | ||
| age = value; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public int Lard | ||
| { | ||
| get | ||
| { | ||
| return lard; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| if (value < 0) | ||
| { | ||
| lard = 0; | ||
| } | ||
| else | ||
| { | ||
| lard = value; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| if (lard == 0) | ||
| { | ||
| return $"{Name} Без сала\n"; | ||
| } | ||
| else | ||
| { | ||
| return $"Из {Name} можно получить {Lard} сала\n"; | ||
| } | ||
| } | ||
|
Comment on lines
+101
to
+111
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Прям с любого животного? что-то не так с абстракциями |
||
|
|
||
| public abstract string Died(); | ||
|
|
||
| public abstract string MakePhrase(string[] phraseArray); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Этот метод тут не нужен (да и в дочерних тоже) |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
| /* using System.Collections.Generic;*/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented code |
||
|
|
||
| public class Bull : Animals | ||
| { | ||
| private Random random = new Random(); | ||
|
|
||
| public Bull() | ||
| : base() | ||
| { | ||
| } | ||
|
|
||
| public Bull(string name, int weight) | ||
| : base(name, weight) | ||
| { | ||
| } | ||
|
|
||
| public Bull(string name, int weight, int lard) | ||
| : base(name, weight, lard) | ||
| { | ||
| } | ||
|
|
||
| public Bull(string name, int weight, int age, int lard) | ||
| : base(name, weight, age, lard) | ||
| { | ||
| } | ||
|
|
||
| public override string Died() | ||
| { | ||
| int lard = Lard; | ||
| Lard = 0; | ||
| return $"{Name} убит\nПолучено {lard} сала\n"; | ||
| } | ||
|
Comment on lines
+30
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? Сало? same as for pig? |
||
|
|
||
| public override string MakePhrase(string[] phraseArray) | ||
| { | ||
| int index = random.Next(0, 3); | ||
| string phrase = phraseArray[index]; | ||
| return $"{phrase}"; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| namespace CourseApp | ||
| { | ||
| public class Calculator | ||
| { | ||
| public int GetSum(int a, int b) | ||
| { | ||
| return a + b; | ||
| } | ||
|
|
||
| public double GeSum(double a, double b) | ||
| { | ||
| return a + b; | ||
| } | ||
|
|
||
| public int GetProduct(int a, int b) | ||
| { | ||
| return a * b; | ||
| } | ||
|
|
||
| public double GetQuotient(double a, double b) | ||
| { | ||
| return a / b; | ||
| } | ||
| } | ||
| } |
This file was deleted.
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.
Please - use Inline data to check multiple cases