Add Lesson 4 Task 4
This commit is contained in:
parent
b5db4e4640
commit
3f6406ab69
8 changed files with 113 additions and 0 deletions
13
Lesson_4/Task_4/Interfaces/IFlyable.cs
Normal file
13
Lesson_4/Task_4/Interfaces/IFlyable.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LiskovSubstitution.Interfaces
|
||||||
|
{
|
||||||
|
public interface IFlyable
|
||||||
|
{
|
||||||
|
public void Fly();
|
||||||
|
}
|
||||||
|
}
|
16
Lesson_4/Task_4/Perfomance.cs
Normal file
16
Lesson_4/Task_4/Perfomance.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LiskovSubstitution
|
||||||
|
{
|
||||||
|
public class Perfomance
|
||||||
|
{
|
||||||
|
public void PerformActions()
|
||||||
|
{
|
||||||
|
//Hmmmm...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
Lesson_4/Task_4/Program.cs
Normal file
16
Lesson_4/Task_4/Program.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using LiskovSubstitution.Vehicles;
|
||||||
|
|
||||||
|
// A plane has an engine, and is able to fly
|
||||||
|
Plane plane = new Plane();
|
||||||
|
plane.Fly();
|
||||||
|
plane.StartEngine();
|
||||||
|
|
||||||
|
// A car cannot fly, CS1061 if attempted
|
||||||
|
Car car = new Car();
|
||||||
|
// car.Fly();
|
||||||
|
car.StartEngine();
|
||||||
|
|
||||||
|
// Same for motorcycle
|
||||||
|
Motorcycle motorcycle = new Motorcycle();
|
||||||
|
// motorcycle.Fly();
|
||||||
|
motorcycle.StartEngine();
|
10
Lesson_4/Task_4/Task_4.csproj
Normal file
10
Lesson_4/Task_4/Task_4.csproj
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
12
Lesson_4/Task_4/Vehicles/Car.cs
Normal file
12
Lesson_4/Task_4/Vehicles/Car.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LiskovSubstitution.Vehicles
|
||||||
|
{
|
||||||
|
public class Car : Vehicle
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
12
Lesson_4/Task_4/Vehicles/Motorcycle.cs
Normal file
12
Lesson_4/Task_4/Vehicles/Motorcycle.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LiskovSubstitution.Vehicles
|
||||||
|
{
|
||||||
|
public class Motorcycle : Vehicle
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
18
Lesson_4/Task_4/Vehicles/Plane.cs
Normal file
18
Lesson_4/Task_4/Vehicles/Plane.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using LiskovSubstitution.Interfaces;
|
||||||
|
|
||||||
|
namespace LiskovSubstitution.Vehicles
|
||||||
|
{
|
||||||
|
public class Plane : Vehicle, IFlyable
|
||||||
|
{
|
||||||
|
public virtual void Fly()
|
||||||
|
{
|
||||||
|
Console.WriteLine("It's flying?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
Lesson_4/Task_4/Vehicles/Vehicle.cs
Normal file
16
Lesson_4/Task_4/Vehicles/Vehicle.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace LiskovSubstitution.Vehicles
|
||||||
|
{
|
||||||
|
public class Vehicle
|
||||||
|
{
|
||||||
|
public virtual void StartEngine()
|
||||||
|
{
|
||||||
|
Console.WriteLine("The engine is starting");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in a new issue