Created
March 16, 2017 00:15
-
-
Save prinick96/b08133fcebaaffcd4c2afe57b92bf590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Programa.Interfaces | |
{ | |
interface IMotor | |
{ | |
string EncenderMotor(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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