-
Notifications
You must be signed in to change notification settings - Fork 17
Уточка Мороховцев #2
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
DressCodeBoy
wants to merge
2
commits into
ISUCT:master
Choose a base branch
from
DressCodeBoy:master
base: master
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
2 commits
Select commit
Hold shift + click to select a range
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,20 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp3.1</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.2.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\App\App.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
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,43 @@ | ||
| using System; | ||
| using Xunit; | ||
|
|
||
| namespace App.Tests | ||
| { | ||
| public class UnitTest1 | ||
| { | ||
| [Fact] | ||
| public void Quack() | ||
| { | ||
| Duck donald = new Duck(); | ||
| string str = donald.Quack(); | ||
| Assert.Equal("Я переопределился, но против поправок, ведь я умный утенок.", str); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Display() | ||
| { | ||
| Duck donald = new Duck(); | ||
| string str = donald.Display(); | ||
| Assert.Equal("У уток очень хорошее зрение. Они видят лучше людей и собак.\nТакже они воспринимают окружающий мир в полномасштабной цветовой гамме.", str); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void SpeedFly() | ||
| { | ||
| Duck donald = new Duck(); | ||
| Assert.Equal(50, donald.SpeedFly); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void NicknameAndAge() | ||
| { | ||
| Duck donald = new Duck(); | ||
| Assert.Equal("Дональд", donald.nickname); | ||
| Assert.Equal(10, donald.age); | ||
| donald.nickname = "Duck"; | ||
| donald.age = 15; | ||
| Assert.Equal("Duck", donald.nickname); | ||
| Assert.Equal(15, donald.age); | ||
| } | ||
| } | ||
| } |
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,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp3.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
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,22 @@ | ||
| using System; | ||
|
|
||
| namespace App | ||
| { | ||
| public class Duck : abstractDuck | ||
| { | ||
| public string nickname; | ||
| public int age; | ||
| public Duck() { nickname = "Дональд"; age = 10; } | ||
|
|
||
| public override string Quack() | ||
| { | ||
| return "Я переопределился, но против поправок, ведь я умный утенок."; | ||
| } | ||
| public override string Display() | ||
| { | ||
| return "У уток очень хорошее зрение. Они видят лучше людей и собак.\nТакже они воспринимают окружающий мир в полномасштабной цветовой гамме."; | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } |
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,12 @@ | ||
| namespace App | ||
| { | ||
| interface IFly | ||
| { | ||
| public float SpeedFly { get; } | ||
| public float Distance { get; set; } | ||
| } | ||
| interface IQuack | ||
| { | ||
| string Quack(); | ||
| } | ||
| } |
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,22 @@ | ||
| using System; | ||
|
|
||
| namespace App | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| Duck donald = new Duck(); | ||
| donald.Distance = 40.0F; | ||
| float flightTime = donald.Distance / donald.SpeedFly; | ||
| Console.WriteLine("============================================================"); | ||
| Console.WriteLine(donald.nickname); | ||
| Console.WriteLine(donald.age + " лет"); | ||
| Console.WriteLine($"Время полета (в часах) = {flightTime}"); | ||
| Console.WriteLine(donald.Quack()); | ||
| Console.WriteLine("+++++++++++++++++"); | ||
| Console.WriteLine(donald.Display()); | ||
| Console.WriteLine("============================================================"); | ||
| } | ||
| } | ||
| } |
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,21 @@ | ||
| using System; | ||
|
|
||
| namespace App | ||
| { | ||
| public abstract class abstractDuck : IFly, IQuack // от абстрактного класса нельзя сделать экземпляр | ||
| { | ||
| float speedFly = 50.0F; | ||
| public float SpeedFly => speedFly; // св-во доступно только для чтения | ||
| public float Distance { get; set; } | ||
| public virtual string Quack() // доступный для переопределения virtual метод | ||
| { | ||
| return "Кря Кря Кря Кря"; | ||
| } | ||
| public static string Swim() | ||
| { | ||
| return "*Звуки плескания в воде*"; | ||
| } | ||
|
|
||
| public abstract string Display(); // метод можно вызывать без экземпляра класса | ||
| } | ||
| } | ||
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 +1,5 @@ | ||
| # exam_147_2020 | ||
| # Мороховцев Виктор 2/147 | ||
|
|
||
| Создайте абстрактный класс утка с методом swim, абстрактным методом display, и интерфейсы fly и quack. Показать пример использования класса, наследующего абстрактный класс и реализующими интерфейсы. | ||
|
|
||
| Приветствую одногруппников (Псс. Только не списывай один в один). |
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.
Интерфейсы теряют смысл - а если я хочу в процессе создать утку - которая не летает? как это сделать?
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.
@jskonst в интерфейсе придется прописывать возможность