diff --git a/Lesson_4/Task_4/Interfaces/IFlyable.cs b/Lesson_4/Task_4/Interfaces/IFlyable.cs new file mode 100644 index 0000000..c76dd45 --- /dev/null +++ b/Lesson_4/Task_4/Interfaces/IFlyable.cs @@ -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(); + } +} diff --git a/Lesson_4/Task_4/Perfomance.cs b/Lesson_4/Task_4/Perfomance.cs new file mode 100644 index 0000000..f2ee7ed --- /dev/null +++ b/Lesson_4/Task_4/Perfomance.cs @@ -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... + } + } +} diff --git a/Lesson_4/Task_4/Program.cs b/Lesson_4/Task_4/Program.cs new file mode 100644 index 0000000..25f7fca --- /dev/null +++ b/Lesson_4/Task_4/Program.cs @@ -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(); diff --git a/Lesson_4/Task_4/Task_4.csproj b/Lesson_4/Task_4/Task_4.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/Lesson_4/Task_4/Task_4.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/Lesson_4/Task_4/Vehicles/Car.cs b/Lesson_4/Task_4/Vehicles/Car.cs new file mode 100644 index 0000000..b8a52dc --- /dev/null +++ b/Lesson_4/Task_4/Vehicles/Car.cs @@ -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 + { + } +} diff --git a/Lesson_4/Task_4/Vehicles/Motorcycle.cs b/Lesson_4/Task_4/Vehicles/Motorcycle.cs new file mode 100644 index 0000000..96b6f43 --- /dev/null +++ b/Lesson_4/Task_4/Vehicles/Motorcycle.cs @@ -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 + { + } +} diff --git a/Lesson_4/Task_4/Vehicles/Plane.cs b/Lesson_4/Task_4/Vehicles/Plane.cs new file mode 100644 index 0000000..3e0f0c2 --- /dev/null +++ b/Lesson_4/Task_4/Vehicles/Plane.cs @@ -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?"); + } + } +} diff --git a/Lesson_4/Task_4/Vehicles/Vehicle.cs b/Lesson_4/Task_4/Vehicles/Vehicle.cs new file mode 100644 index 0000000..d9a2a88 --- /dev/null +++ b/Lesson_4/Task_4/Vehicles/Vehicle.cs @@ -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"); + } + } +}