68
1
//Learn LSP at https://www.tutorialsteacher.com/csharp/liskov-substitution-principle
2
using System;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
Rectangle sqr1 = new Square();
9
sqr1.Height = 6;
10
sqr1.Width = 8;
11
12
Console.WriteLine(AreaCalculator.CalculateArea(sqr1)); //returns 64
13
14
Rectangle sqr2 = new Square();
15
sqr2.Height = 8;
16
sqr2.Width = 6;
17
18
Console.WriteLine(AreaCalculator.CalculateArea(sqr2)); //returns 36
19
}
20
}
21
22
public class Rectangle
23
{
24
public virtual int Height { get; set; }
Cached Result
zadej cislo
>