-
Notifications
You must be signed in to change notification settings - Fork 24
Hamraev_Ivan_Dilshodovich #11
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
Gv1don
wants to merge
9
commits into
ISUCT:Hamraev_Ivan_Dilshodovich
Choose a base branch
from
Gv1don:Hamraev_Ivan_Dilshodovich
base: Hamraev_Ivan_Dilshodovich
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
9 commits
Select commit
Hold shift + click to select a range
44a7ac5
Add solution for first task
Gv1don 89bb0b4
Fix on comments
Gv1don 1c8851f
Add correct solution for task
Gv1don 6eba2a3
Poymorphism task
Gv1don 2fcd3de
Add enum with player types
Gv1don 735c369
Rename element of the enum
Gv1don 34fdb73
Create class for creating player
Gv1don 340763b
Add RPGSaga
Gv1don c703476
Corrections on comments
Gv1don 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,18 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
|
|
||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> | ||
| <PackageReference Include="MSTest.TestAdapter" Version="2.2.8" /> | ||
| <PackageReference Include="MSTest.TestFramework" Version="2.2.8" /> | ||
| <PackageReference Include="coverlet.collector" Version="3.1.2" /> | ||
| </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,11 @@ | ||
| namespace CourseApp.RPGSagaTests | ||
| { | ||
| [TestClass] | ||
| public class UnitTest1 | ||
| { | ||
| [TestMethod] | ||
| public void TestMethod1() | ||
| { | ||
| } | ||
| } | ||
| } |
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,49 @@ | ||
| namespace CourseApp.Tests | ||
| { | ||
| using CourseApp.RPGSaga; | ||
| using Xunit; | ||
|
|
||
| public class AutoMethodsTests | ||
| { | ||
| [Fact] | ||
| public void GetInfo_SetSampleData_ReturnCorrectInfo_Auto() | ||
| { | ||
| Transport auto = new Auto(4.9, 1.71, 2145, 333, 250, "Audi Q8"); | ||
| Assert.Equal( | ||
| @"Info for Audi Q8 | ||
| Weight: 2145 kg | ||
| Length: 4,9 m | ||
| Height: 1,71 m | ||
| Power: 333 horsepower | ||
| Max Speed: 250 km\h", auto.GetInfo()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CheckConstructor_SetSampleData_ReturnCorrectInfo_Auto() | ||
| { | ||
| Transport auto = new Auto(); | ||
|
|
||
| Assert.Equal( | ||
| @"Info for Auto | ||
| Weight: 0 kg | ||
| Length: 0 m | ||
| Height: 0 m | ||
| Power: 0 horsepower | ||
| Max Speed: 0 km\h", auto.GetInfo()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Movement_CallMovementMethod_CorrectMove_Auto() | ||
| { | ||
| Transport auto = new Auto(); | ||
| Assert.Equal(ActionTypes.Move, auto.Movement()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ToString_CheckStringPresentation_CorrectPresentationOfInstance() | ||
| { | ||
| Transport auto = new Auto(4.9, 1.71, 2145, 333, 250, "Audi Q8"); | ||
| Assert.Equal("Auto Audi Q8", auto.ToString()); | ||
| } | ||
| } | ||
| } |
This file was deleted.
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,63 @@ | ||
| namespace CourseApp.Tests | ||
| { | ||
| using CourseApp.RPGSaga; | ||
| using Xunit; | ||
|
|
||
| public class PlaneMethodsTests | ||
| { | ||
| [Fact] | ||
| public void GetInfo_SetSampleData_ReturnCorrectInfo() | ||
| { | ||
| Transport plane = new Plane(9.22, 2.74, 1361, 450, 255, "DHC-2 Beaver"); | ||
| Assert.Equal( | ||
| @"Info for DHC-2 Beaver | ||
| Weight: 1361 kg | ||
| Length: 9,22 m | ||
| Height: 2,74 m | ||
| Power: 450 horsepower | ||
| Max Speed: 255 km\h", plane.GetInfo()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CheckConstructor_SetSampleData_ReturnCorrectInfo() | ||
| { | ||
| Transport plane = new Plane(); | ||
|
|
||
| Assert.Equal( | ||
| @"Info for Plane | ||
| Weight: 0 kg | ||
| Length: 0 m | ||
| Height: 0 m | ||
| Power: 0 horsepower | ||
| Max Speed: 0 km\h", plane.GetInfo()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Movement_CallMovementMethod_CorrectMoveInfo() | ||
| { | ||
| var plane = new Plane(); | ||
| Assert.Equal(ActionTypes.Move, plane.Movement()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Landing_CallLandingMethod_CorrectLandingInfo() | ||
| { | ||
| var plane = new Plane(); | ||
| Assert.Equal(ActionTypes.LAnding, plane.Landing()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Takeoff_CallLandingMethod_CorrectTakeoffInfo() | ||
| { | ||
| var plane = new Plane(); | ||
| Assert.Equal(ActionTypes.TAkeoff, plane.Takeoff()); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ToString_CheckStringPresentation_CorrectPresentationOfInstance() | ||
| { | ||
| Transport plane = new Plane(9.22, 2.74, 1361, 450, 255, "DHC-2 Beaver"); | ||
| Assert.Equal("Plane DHC-2 Beaver", plane.ToString()); | ||
| } | ||
| } | ||
| } |
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,33 @@ | ||
| namespace CourseApp.RPGSaga | ||
| { | ||
| /// <summary> | ||
| /// Types of actions. | ||
| /// </summary> | ||
| public enum ActionTypes | ||
| { | ||
| /// <summary> | ||
| /// No type. | ||
| /// </summary> | ||
| Nothing, | ||
|
|
||
| /// <summary> | ||
| /// Type for movement. | ||
| /// </summary> | ||
| Move, | ||
|
|
||
| /// <summary> | ||
| /// Type for takeoff. | ||
| /// </summary> | ||
| TAkeoff, | ||
|
|
||
| /// <summary> | ||
| /// Types for landing. | ||
| /// </summary> | ||
| LAnding, | ||
|
|
||
| /// <summary> | ||
| /// Types for beep. | ||
| /// </summary> | ||
| BEep, | ||
| } | ||
| } | ||
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,38 @@ | ||
| namespace CourseApp.RPGSaga | ||
| { | ||
| using System; | ||
|
|
||
| public class Auto : Transport | ||
| { | ||
| private ActionTypes actionType; | ||
|
|
||
| public Auto() | ||
| : this(0, 0, 0, 0, 0, "Auto") | ||
| { | ||
| } | ||
|
|
||
| public Auto(double length, double height, int weight, int power, int maxSpeed, string model) | ||
| : base(length, height, weight, power, maxSpeed, model) | ||
| { | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return $"Auto {Model}"; | ||
| } | ||
|
|
||
| public override ActionTypes Movement() | ||
| { | ||
| actionType = ActionTypes.Move; | ||
| Console.WriteLine($"{Model} is moving at a speed {Speed}km/h"); | ||
| return actionType; | ||
| } | ||
|
|
||
| public ActionTypes Beep() | ||
| { | ||
| actionType = ActionTypes.BEep; | ||
| Console.WriteLine("Beep"); | ||
| return actionType; | ||
| } | ||
| } | ||
| } |
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,6 @@ | ||
| namespace CourseApp.RPGSaga; | ||
|
|
||
| public interface ILanding | ||
| { | ||
| public ActionTypes Landing(); | ||
| } |
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,6 @@ | ||
| namespace CourseApp.RPGSaga; | ||
|
|
||
| public interface ITakeoff | ||
| { | ||
| public ActionTypes Takeoff(); | ||
| } |
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,47 @@ | ||
| namespace CourseApp.RPGSaga | ||
| { | ||
| using System; | ||
|
|
||
| public class Plane : Transport, ILanding, ITakeoff | ||
| { | ||
| private ActionTypes actionType; | ||
|
|
||
| public Plane() | ||
| : this(0, 0, 0, 0, 0, "Plane") | ||
| { | ||
| } | ||
|
|
||
| public Plane(double length, double height, int weight, int power, int maxSpeed, string model) | ||
| : base(length, height, weight, power, maxSpeed, model) | ||
| { | ||
| } | ||
|
|
||
| public string Direction { get; set; } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return $"Plane {Model}"; | ||
| } | ||
|
|
||
| public ActionTypes Takeoff() | ||
| { | ||
| actionType = ActionTypes.TAkeoff; | ||
| Console.WriteLine($"{Model} taking off"); | ||
| return actionType; | ||
| } | ||
|
|
||
| public ActionTypes Landing() | ||
| { | ||
| actionType = ActionTypes.LAnding; | ||
| Console.WriteLine($"{Model} going to land"); | ||
| return actionType; | ||
| } | ||
|
|
||
| public override ActionTypes Movement() | ||
| { | ||
| actionType = ActionTypes.Move; | ||
| Console.WriteLine($"{Model} is moving at a speed {Speed}km/h in the {Direction}"); | ||
| return actionType; | ||
| } | ||
| } | ||
| } |
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,77 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
| using CourseApp.RPGSaga; | ||
|
|
||
| public abstract class Transport | ||
| { | ||
| private int _speed; | ||
|
|
||
| public Transport() | ||
| : this(0, 0, 0, 0, 0, "No_name") | ||
| { | ||
| } | ||
|
|
||
| public Transport(double length, double height, int weight, int power, int maxSpeed, string model) | ||
| { | ||
| Length = length; | ||
| Weight = weight; | ||
| Power = power; | ||
| Height = height; | ||
| MaxSpeed = maxSpeed; | ||
| Model = model; | ||
| } | ||
|
|
||
| public string Model { get; set; } | ||
|
|
||
| public int Power { get; } | ||
|
|
||
| public double Length { get; } | ||
|
|
||
| public int Weight { get; } | ||
|
|
||
| public double Height { get; } | ||
|
|
||
| public int MaxSpeed { get; } | ||
|
|
||
| public int Speed | ||
| { | ||
| get | ||
| { | ||
| return _speed; | ||
| } | ||
|
|
||
| set | ||
| { | ||
| try | ||
| { | ||
| if (value > MaxSpeed || value < 0) | ||
| { | ||
| throw new Exception($"speed is too large or too little for {Model}"); | ||
| } | ||
| else | ||
| { | ||
| _speed = value; | ||
| } | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| new ArgumentException($"Error: {e.Message}"); | ||
| Console.WriteLine($"Error: {e.Message}"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public abstract ActionTypes Movement(); | ||
|
|
||
| public string GetInfo() | ||
| { | ||
| return @$"Info for {Model} | ||
| Weight: {Weight} kg | ||
| Length: {Length} m | ||
| Height: {Height} m | ||
| Power: {Power} horsepower | ||
| Max Speed: {MaxSpeed} km\h"; | ||
| } | ||
| } | ||
| } |
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
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.
Зачем ?