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
public boolean myFunction() { | |
boolean result = someObject.someMethod(); | |
if (result) { | |
... some code ... | |
if (second-test) { | |
... code on true ... | |
return true | |
} | |
... code on false ... |
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
public boolean myFunction() { | |
boolean result = someObject.someMethod(); | |
if (result) { | |
... some code ... | |
if (second-test) { | |
... code on true ... | |
return true | |
} else { | |
... code on false ... |
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
public boolean myFunction() { | |
boolean result = someObject.someMethod(); | |
if (result) { | |
... some code ... | |
return true; | |
} else { | |
... log error maybe ... | |
return false | |
} |
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
public boolean myFunction() { | |
boolean result = someObject.someMethod(); | |
if (result) { | |
... some code ... | |
return true; | |
} | |
... log error maybe ... | |
return false |
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 Television { | |
void _illuminateDisplay() { | |
print ("Display ON"); | |
} | |
void _activateIrSensor() { | |
print ("IR sensor ON"); | |
} | |
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 Rectangle { | |
num left, top, width, height; | |
Rectangle(this.left, this.top, this.width, this.height); | |
// Define two calculated properties: right and bottom. | |
num get right => left + width; | |
set right(num value) => left = value - width; | |
num get bottom => top + height; | |
set bottom(num value) => top = value - height; |
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 Pessoa { | |
// atributos | |
String nome; | |
int idade; | |
// construtor | |
Pessoa (String nome, {int idade}) { | |
this.nome = nome; | |
this.idade = idade; | |
} |
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 Pessoa { | |
// atributos | |
String nome; | |
int idade; | |
// métodos | |
void cumprimentar(String nome) { | |
print ("Olá " + nome + " me chamo " + this.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
// Função sem parâmetros | |
void escreverBemVindo(){ | |
print("Seja bem-vindo!"); | |
} | |
// Quando a função só tem um comando interno | |
// Substitui abertura e fechamento de bloco, e o comando return | |
void escreverTipoFuncao() => print("Função com um comando."); | |
// Função com passagem de parâmetros (podem ter quantos parâmetros quiser) |
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(){ | |
// Repetição de 0 a 5 (conhecemos o número inicial e final) | |
// FOR (INICIO; CONDIÇÃO; INCREMENTO) | |
for(int i = 0; i < 5; i++){ | |
print("For " + i.toString()); | |
} | |
// Repetição de 0 a 5 | |
// INICIO; WHILE (CONDICAO){ INCREMENTO; } | |
// Teste condicional no início |