Skip to content

Instantly share code, notes, and snippets.

@zs40x
Last active April 23, 2016 13:01
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 zs40x/8ffa7f9cf2ca1a8335672c52e352198b to your computer and use it in GitHub Desktop.
Save zs40x/8ffa7f9cf2ca1a8335672c52e352198b to your computer and use it in GitHub Desktop.
namespace LiskovSubstitutionPrinciple.Violation
{
public class Rectangle
{
protected int _width;
protected int _height;
public virtual int Height
{
get { return _height; }
set { _height = value; }
}
public virtual int Width
{
get { return _width; }
set { _width = value; }
}
public int Area => _width * _height;
}
public class Square : Rectangle
{
public override int Height
{
get
{
return _height;
}
set
{
_width = value;
_height = value;
}
}
public override int Width
{
get
{
return _width;
}
set
{
_width = value;
_height = value;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment