using System.Collections.Generic;
public static void Main(string[] args)
List<GrafickyObjekt> objekty = new List<GrafickyObjekt> { new Obdelnik(5, 4), new Trojuhelnik(10), new Text("Ahoj různé tvary") };
foreach (var tvary in objekty)
public class GrafickyObjekt
public virtual void Vykresli()
public virtual void NastavBarvu()
Console.ForegroundColor = ConsoleColor.DarkYellow;
public class Obdelnik : GrafickyObjekt
public override void NastavBarvu()
Console.ForegroundColor = ConsoleColor.Red;
public override void Vykresli()
for (int i = 0; i < Sirka; i++)
for (int i = 0; i < Vyska - 2; i++)
for (int y = 0; y < Sirka - 2; y++)
for (int i = 0; i < Sirka; i++)
public Obdelnik(int vyska, int sirka)
public class Trojuhelnik : GrafickyObjekt
public override void NastavBarvu()
Console.ForegroundColor = ConsoleColor.Green;
public override void Vykresli()
for (int i = 0; i < Vyska; i++)
for (int y = 0; y <= i; y++)
if (i > 1 && i < Vyska - 1)
public Trojuhelnik(int vyska)
public class Text : GrafickyObjekt
public string Retezec { get => retezec; set => retezec = value; }
public override void NastavBarvu()
Console.ForegroundColor = ConsoleColor.White;
public override void Vykresli()
Console.WriteLine(retezec);
public Text(string retezec)