Skip to content

Instantly share code, notes, and snippets.

@uqmessias
Last active October 16, 2016 02:27
Show Gist options
  • Save uqmessias/494b5d55940549498750b2a19fb5e2dd to your computer and use it in GitHub Desktop.
Save uqmessias/494b5d55940549498750b2a19fb5e2dd to your computer and use it in GitHub Desktop.
void Main()
{
FormasGeometricas[] formas = new FormasGeometricas[2];
formas[0] = new Quadrado(3);
formas[1] = new Retangulo(2, 4);
for(int i = 0;i < formas.Length;i++)
{
Console.WriteLine(formas[i].Area());
}
}
public abstract class FormasGeometricas
{
public abstract float Area();
}
public class Quadrado : FormasGeometricas
{
public float Lado {get; private set;}
public Quadrado(float lado)
{
Lado = lado;
}
public override float Area()
{
return Lado * Lado;
}
}
public class Retangulo : FormasGeometricas
{
public float Altura {get; private set;}
public float Largura {get; private set;}
public Retangulo(float altura, float largura)
{
Altura = altura;
Largura = largura;
}
public override float Area()
{
return Altura * Largura;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment