Articles → .NET → Interface Segregation Principal C#

Interface Segregation Principal C#

















public interface IInsurance
{
    void CarInsurance();
    void MedicalInsurance();
    void TermInsurance();
}




public class Children : IInsurance
{
    public void CarInsurance()
    {
        throw new NotImplementedException();
    }

    public void MedicalInsurance()
    {
        throw new NotImplementedException();
    }

    public void TermInsurance()
    {
        throw new NotImplementedException();
    }
}
public class ServiceMan : IInsurance
{
    public void CarInsurance()
    {
        throw new NotImplementedException();
    }

    public void MedicalInsurance()
    {
        throw new NotImplementedException();
    }

    public void TermInsurance()
    {
        throw new NotImplementedException();
    }
}

public class BusinessMan : IInsurance
{
    public void CarInsurance()
    {
        throw new NotImplementedException();
    }

    public void MedicalInsurance()
    {
        throw new NotImplementedException();
    }

    public void TermInsurance()
    {
        throw new NotImplementedException();
    }
}

public class OldAge : IInsurance
{
    public void CarInsurance()
    {
        throw new NotImplementedException();
    }

    public void MedicalInsurance()
    {
        throw new NotImplementedException();
    }

    public void TermInsurance()
    {
        throw new NotImplementedException();
    }
}





















Interface segregation principle for rescue




public interface ICarInsurance
{
    void CarInsurance();
}

public interface IMedicalInsurance
{
    void MedicalInsurance();
}
public interface ITermInsurance
{
    void TermInsurance();
}




public class Children : IMedicalInsurance
{

    public void MedicalInsurance()
    {
        throw new NotImplementedException();
    }
}
public class ServiceMan : ICarInsurance,ITermInsurance
{

    public void CarInsurance()
    {
        throw new NotImplementedException();
    }

    public void TermInsurance()
    {
        throw new NotImplementedException();
    }
}

public class BusinessMan : ICarInsurance,IMedicalInsurance,ITermInsurance
{

    public void CarInsurance()
    {
        throw new NotImplementedException();
    }

    public void MedicalInsurance()
    {
        throw new NotImplementedException();
    }

    public void TermInsurance()
    {
        throw new NotImplementedException();
    }
}

public class OldAge : ICarInsurance
{

    public void CarInsurance()
    {
        throw new NotImplementedException();
    }
}





Posted By  -  Karan Gupta
 
Posted On  -  Thursday, June 04, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250