public abstract class Shape {
//Soyut sınıftır çünkü doğrudan bir Shape üretilmesini istemeyiz.
public virtual int CalculateArea();
public Point Location { get; set; }
public List<int> BorderLengths { get; set; }
}
public class Square : Shape {
public Square(Point location, int borderLength) {
Location = location;
BorderLengths =
new List<int>(){ borderLength, borderLength, borderLength, borderLength };
}
public override int CalculateArea(){
int borderLength = BorderLengths[0];
return borderLength * borderLength;
}
}
public class Rectangle : Shape {
public Rectangle(Location location, int longBorderLength, int shortBorderLength){
Location = location;
BorderLengths =
new List<int>(){ longBorderLength, shortBorderLength, longBorderLength, shortBorderLength };
}
public override int CalculateArea(){
int long = BorderLengths[0];
int short = BorderLengths[1];
return long * short;
}
}