Skip to content

Instantly share code, notes, and snippets.

@prinick96
Created March 16, 2017 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prinick96/b08133fcebaaffcd4c2afe57b92bf590 to your computer and use it in GitHub Desktop.
Save prinick96/b08133fcebaaffcd4c2afe57b92bf590 to your computer and use it in GitHub Desktop.
using Programa.Interfaces;
namespace Programa.Clases
{
class Carro
{
IMotor motor;
public Carro(IMotor motor)
{
this.motor = motor;
}
public string EncenderCarro()
{
return "Se enciende el carro y también " + motor.EncenderMotor();
}
}
}
using Programa.Interfaces;
namespace Programa.Clases
{
class MotorDiesel : IMotor
{
private string type_motor;
public MotorDiesel()
{
type_motor = "Diesel";
}
public string EncenderMotor()
{
return "Está encendiendo el motor a " + type_motor;
}
}
}
using Programa.Interfaces;
namespace Programa.Clases
{
class MotorGasolina : IMotor
{
private string type_motor;
public MotorGasolina()
{
type_motor = "Gasolina";
}
public string EncenderMotor()
{
return "Está encendiendooo el motor a " + type_motor;
}
}
}
namespace Programa.Interfaces
{
interface IMotor
{
string EncenderMotor();
}
}
using System;
using Programa.Clases;
namespace Programa {
class Programa
{
static void Main(string[] args)
{
Carro ferrari = new Carro(new MotorGasolina(44));
Console.WriteLine(ferrari.EncenderCarro());
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment