Last active
April 6, 2024 19:33
-
-
Save lucasres/86bc0ea22e48f47de04f2a57c3dc8e05 to your computer and use it in GitHub Desktop.
Atividade IFPI Lista funções em dart
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
void main() { | |
mensagemAtividade("01"); | |
print(multiplicaNumeros(10, 50)); | |
mensagemAtividade("02"); | |
print(construirNomeCompleto("Lucas", "Resende")); | |
mensagemAtividade("03"); | |
print(construirNomeCompletoNullable("Lucas")); | |
print(construirNomeCompletoNullable("Lucas", "Resende")); | |
mensagemAtividade("04"); | |
print(descreverCidade("Piracuruca")); | |
print(descreverCidade("Londres", "Reino Unido")); | |
mensagemAtividade("05"); | |
var quadrado = (int x){return x * x;}; | |
print(quadrado(9)); | |
mensagemAtividade("06"); | |
var quadradoSeta = (int x) => x * x; | |
print(quadradoSeta(9)); | |
mensagemAtividade("07"); | |
print(aplicarOperacao(9, 8, (int a, int b) => a - b)); | |
print(aplicarOperacao(10, 2, (int a, int b) => a / b)); | |
mensagemAtividade("08"); | |
print(maiorNumero([1,5,3,5,67,34,42,34,3,4,-3])); | |
mensagemAtividade("09"); | |
Map<String, int> estoque = new Map(); | |
estoque["Memoria RAM"] = 10; | |
estoque["Intel Core i5"] = 29; | |
estoque["Mouse AttackShark"] = 3; | |
estoque["Roteador TPLink"] = 12; | |
imprimirEstoque(estoque); | |
mensagemAtividade("10"); | |
configurarUsuario("Lucas"); | |
configurarUsuario("Lucas", 28); | |
configurarUsuario("Lucas", 28, "[email protected]"); | |
} | |
void mensagemAtividade(String nome) { | |
print("Atividade $nome"); | |
} | |
String construirNomeCompleto(String nome, String sobrenome) { | |
return "$nome $sobrenome"; | |
} | |
String construirNomeCompletoNullable(String nome, [String? sobrenome]) { | |
if (sobrenome != null) { | |
return "$nome $sobrenome"; | |
} | |
return nome; | |
} | |
String descreverCidade(String cidade, [String? pais]) { | |
if (pais == null) { | |
pais = "Brasil"; | |
} | |
return "Cidade: $cidade, Pais: $pais"; | |
} | |
int multiplicaNumeros(int a, int b) { | |
return a * b; | |
} | |
int aplicarOperacao(int a , int b, Function operacao) { | |
return operacao(a, b); | |
} | |
int maiorNumero(List<int> l) { | |
int maior = 0; | |
for (int i = 0; i < l.length; i++) { | |
var elemento = l[i]; | |
if (elemento > maior) { | |
maior = l[i]; | |
} | |
} | |
return maior; | |
} | |
void imprimirEstoque(Map<String, int> e) { | |
e.forEach((k, v) => print("Nome: $k | Quantidade: $v")); | |
} | |
void configurarUsuario(String nome, [int idade = 18, String? email]){ | |
var resultado = "Nome: $nome, Idade: $idade"; | |
if(email != null){ | |
resultado += ", Email: $email"; | |
} | |
print(resultado); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment