Last active
June 29, 2017 13:29
-
-
Save lrlucena/ca79b1273fa503dfe8aab4a73f58ac2a to your computer and use it in GitHub Desktop.
Definindo novos tipos
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
tipo Dado | |
lados: Inteiro | |
var valor = aleatório(1, lados) | |
rolar() | |
valor := aleatório(1, lados) | |
fim | |
fim | |
d1 = Dado(6) | |
escreva d1.valor | |
d1.rolar | |
escreva d1.valor |
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
tipo Pessoa | |
nome: Texto | |
email: Texto | |
idade: Inteiro | |
# instituicao = "IFRN" | |
fim | |
a = 10 | |
b = "IFRN" | |
c = Pessoa("Potigol", "[email protected]", 6) | |
joao = Pessoa("Joao", "[email protected]", 19) | |
agenda = [c, joao] | |
escreva agenda[1].nome | |
escreva c.nome | |
escreva c.idade | |
escreva c | |
escreva joao.nome |
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
tipo Quadrado | |
lado: Real | |
area() = lado ^ 2 | |
perimetro() = lado * 4 | |
fim | |
tipo Circulo | |
raio: Real | |
perimetro() = 2 * 3.14 * raio | |
fim | |
q1 = Quadrado(10) | |
q2 = Quadrado(20) | |
escreva q1.lado | |
escreva "Área = {q1.area}" | |
escreva "Perímetro = {q1.perimetro}" | |
escreva q2.area |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment