Last active
October 20, 2015 20:47
-
-
Save abacha/6ad5d9e08333bdd3d18e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class FormaGeometrica { } | |
| class Quadrado implements FormaGeometrica { | |
| int lado; | |
| } | |
| class Retangulo implements FormaGeometrica { | |
| int ladoA, ladoB; | |
| } | |
| class Desenhador { | |
| int calcularArea(FormaGeometrica formaGeometrica) { | |
| int area; | |
| if (formaGeometrica instanceof Quadrado) { | |
| area = lado ^ 2; | |
| } | |
| elseif (formaGeometrica instanceof Retangulo) { | |
| area = ladoA * ladoB; | |
| } | |
| return area; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment