Last active
October 16, 2016 02:27
-
-
Save uqmessias/494b5d55940549498750b2a19fb5e2dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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