Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions CourseApp.Tests/FoxTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using Xunit;
using Fauna;

namespace CourseApp.Tests
{
public class FoxTest
{
[Fact]
public void Test1()
{
Fox africa = new Fox("Neznaem", "White", 25, 30);
Assert.Equal("Unknow", africa.Gender);
Assert.Equal("White", africa.Color);
Assert.Equal(25, africa.Weight);
Assert.Equal(30, africa.Growth);
}

[Fact]
public void Test2()
{
Fox europe = new Fox("Female", -15);
Assert.Equal("Female", europe.Gender);
Assert.Equal(0, europe.Weight);
}

[Fact]
public void Test3()
{
Fox europe = new Fox("Koshka", -3);
Assert.Equal("Unknow", europe.Gender);
Assert.Equal(0, europe.Weight);
}

[Fact]
public void Test4()
{
Fox europe = new Fox("Male", 28);
Assert.Equal("Male", europe.Gender);
Assert.Equal(28, europe.Weight);
}

[Fact]
public void Test5()
{
Fox africa = new Fox("Male", "Blond", 13, -5);
Assert.Equal("Male", africa.Gender);
Assert.Equal("Blond", africa.Color);
Assert.Equal(13, africa.Weight);
Assert.Equal(0, africa.Growth);
}

[Fact]
public void Test6()
{
Fox africa = new Fox("Neznaem", "", -25, -30);
Assert.Equal("Unknow", africa.Gender);
Assert.Equal("UnknowColor", africa.Color);
Assert.Equal(0, africa.Weight);
Assert.Equal(0, africa.Growth);
}

[Fact]
public void Test7()
{
Fox africa = new Fox("Male", "555", 15, 20);
Assert.Equal("Male", africa.Gender);
Assert.Equal("UnknowColor", africa.Color);
Assert.Equal(15, africa.Weight);
Assert.Equal(20, africa.Growth);
}
}
}
2 changes: 1 addition & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
31 changes: 31 additions & 0 deletions CourseApp/CourseApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{C95F0266-E3E5-484C-858A-D4C61EC6A4AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{22805653-2FE6-40B8-B856-4D9884187751}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Release|Any CPU.Build.0 = Release|Any CPU
{22805653-2FE6-40B8-B856-4D9884187751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22805653-2FE6-40B8-B856-4D9884187751}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22805653-2FE6-40B8-B856-4D9884187751}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22805653-2FE6-40B8-B856-4D9884187751}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0DEB2E85-CECB-44FB-B010-E7DF83EC7B26}
EndGlobalSection
EndGlobal
100 changes: 100 additions & 0 deletions CourseApp/Fox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;

namespace Fauna
{
public class Fox
{
private string gender;
private string color;
private int weight;
private int growth;

public Fox(string gender, string color, int weight, int growth)
{


this.Gender = gender;
this.Color = color;
this.Weight = weight;
this.Growth = growth;
}

public Fox(string gender, int weight)
: this(gender, string.Empty, weight, 0)
{
}

public string Gender
{
get => gender;
set
{
if (value == $"Male")
{
gender = value;
}
else if (value == $"Female")
{
gender = value;
}
else
{
gender = $"Unknow";
}

}


}

public string Color
{
get => color;
set
{
if (value == $"White")
{
color = value;
}
else if (value == $"Blond")
{
color = value;
}
else if (value == $"Red")

{
color = value;
}
else if (value == string.Empty)
{
color = $"UnknowColor";
}
else
{
color = $"UnknowColor";
}

}
}

public int Weight
{
get => weight;
set
{
weight = value > 0 ? value : 0;
}
}

public int Growth
{
get => growth;
set
{
growth = value > 0 ? value : 0;
}
}

public void GetInfo() => Console.WriteLine($"Пол: {gender} Цвет: {color} Вес: {weight} Рост: {growth}");
}
}
14 changes: 13 additions & 1 deletion CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System;
using Fauna;


namespace Matem


{
public class Program
{
Expand Down Expand Up @@ -34,6 +37,15 @@ static void Main(string[] args)
{
Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}");
}


Fox africa = new Fox($"Male", $"White", 25, 30);
Fox europe = new Fox($"Female", 15);
africa.GetInfo();
europe.GetInfo();

Console.ReadKey();

}
}
}