Add Lesson 4 Task 4

This commit is contained in:
Stanislav Mykhailenko 2023-04-09 21:20:58 +03:00
parent b5db4e4640
commit 3f6406ab69
GPG key ID: 1E95E66A9C9D6A36
8 changed files with 113 additions and 0 deletions

View 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();
}
}

View 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...
}
}
}

View 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();

View 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>

View 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
{
}
}

View 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
{
}
}

View 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?");
}
}
}

View 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");
}
}
}