Consider a building has lift(s) and each lift has some functionalities(Up,Down,Open,Close etc).
I need to design a program which will allow me to add a new lift to the building also new functionalities to the lift. I have to use solid principle for this.
I need some pseudo code or idea to design this.
Note: While adding new feature to the lift it should not force other lifts to add the same feature.
class Lift : ILiftFunctions
{
public void Close()
{
//some logic;
}
public void EmergencyExit()
{
//some logic;
}.... so on
}
---------
public interface ILiftFunctions : ILiftUPDown, ILiftOpenCLose
{
void EmergencyExit();
}
public interface ILiftUPDown
{
void MoveUp();
void MoveDown();
}
public interface ILiftOpenCLose
{
void Open();
void Close();
}
--------
interface IAddLift
{
void AddNewLift(Lift objLift);
}
------------
class Building:IAddLift
{
public int Height { get; set; }
public int Area { get; set; }
public string Name { get; set; }
public List<Lift> lstLifts { get; set; }
public void AddNewLift(Lift objLift)
{
lstLifts.Add(objLift);
}
}
Aucun commentaire:
Enregistrer un commentaire