Interface IFlyable:
namespace exercise75.Models;
internal interface IFlyable
{
public void Fly();
public void Land();
}
Interface IPilotable:
namespace exercise75.Models;
internal interface IPilotable
{
public void Brake();
public void Accelerate();
}
Classe Vehicle:
namespace exercise75.Models;
internal class Vehicle : IFlyable, IPilotable
{
public void Brake()
{
Console.WriteLine("Braking the vehicle...");
return;
}
public void Accelerate()
{
Console.WriteLine("Accelerating the vehicle...");
return;
}
public void Fly()
{
Console.WriteLine("Taking off the vehicle...");
return;
}
public void Land()
{
Console.WriteLine("Landing the vehicle...");
return;
}
}
Instância:
using exercise75.Models;
Vehicle vehicle = new Vehicle();
vehicle.Accelerate();
vehicle.Brake();
vehicle.Fly();
vehicle.Land();