Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
433 changes: 433 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions App.Tests/App.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\App\App.csproj" />
</ItemGroup>

</Project>
35 changes: 35 additions & 0 deletions App.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using Xunit;

namespace App.Tests
{
public class UnitTest1
{
[Fact]
public void Display()
{
Duck duck = new Duck("Утьоночек", 3, 5, true);
string str = duck.Display();
Assert.Equal("Уточки - милые создания", str);
}

[Fact]
public void Area()
{
Duck duck = new Duck("Утьоночек", 3, 5, true);
string str = duck.PlaceOfLiving();
Assert.Equal("Я живу на озере, если что", str);
Duck duck2 = new Duck("Дональд", 4, 10, false);
string str2 = duck2.PlaceOfLiving();
Assert.Equal("Живу на реке, держу в курсе", str2);
}

[Fact]
public void FlightDirection()
{
Duck duck = new Duck("Утьоночек", 3, 5, true);
string str = duck.FlightDirection();
Assert.Equal("Я улетаю на юг!!!", str);
}
}
}
8 changes: 8 additions & 0 deletions App/App.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

</Project>
63 changes: 63 additions & 0 deletions App/Duck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;

namespace App
{
public class Duck : absDuck
{
public string name;
public int count;
public bool isLake;
public int age;

public int Age
{
get
{
return age;
}
set
{
if ( age >= 0 && age < 20)
{
age = value;
}
else
{
Console.WriteLine("Установите возраст от 0 до 20");
}
}
}
public Duck(string name, int age, int count, bool isLake) { this.name = name; Age = age; Count = count; this.isLake = isLake; }

public override int Count
{
get
{
return count;
}
set
{
count = value;
}
}

public override string PlaceOfLiving()
{
if (isLake == true)
{
return "Я живу на озере, если что";
}
else
{
return "Живу на реке, держу в курсе";
}
}

public override string Display()
{
return "Уточки - милые создания";
}


}
}
12 changes: 12 additions & 0 deletions App/Interfaces.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace App
{
interface IFly
{
string FlightDirection(); // куда летят
int Count { get; set; } // число уток
}
interface IQuack
{
string PlaceOfLiving(); //где обитает
}
}
18 changes: 18 additions & 0 deletions App/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace App
{
class Program
{
static void Main(string[] args)
{
Duck krya = new Duck("Утьоночек", 3, 5, true);
Console.WriteLine(krya.name);
Console.WriteLine(krya.Age + " лет");
Console.WriteLine($"Нас {krya.Count}");
Console.WriteLine(krya.PlaceOfLiving());
Console.WriteLine("+++++++++++++++++");
Console.WriteLine(krya.Display());
}
}
}
23 changes: 23 additions & 0 deletions App/absDuck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;

namespace App
{
public abstract class absDuck : IFly, IQuack
{
public string FlightDirection()
{
return "Я улетаю на юг!!!";
}
public virtual int Count { get; set; }
public virtual string PlaceOfLiving()
{
return "Я уточка, живу где хочу";
}
public static string Swim()
{
return "Утки хорошо держатся на поверхности воды благодаря форме тела — оно у неё сплюснутое";
}

public abstract string Display();
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# exam_147_2020
Попова Мария 2/147
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А причем тогда уточка?


Создайте иерархию классов моделирующее игру. Создайте различные виды персонажей и вооружения. Отделите поведение различного типа вооружения. (Используйте интерфейсы для определения поведения)