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
import java.time.LocalDate; | |
public class Pessoa { | |
private final String nome; | |
private final String cpf; | |
private final String rg; | |
private final LocalDate dataNascimento; | |
public Pessoa(String nome, String cpf, String rg, LocalDate dataNascimento) { | |
this.nome = nome; |
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
import java.time.LocalDate; | |
public class Pessoa { | |
private final String nome; | |
private final String cpf; | |
private final String rg; | |
private final LocalDate dataNascimento; | |
private Pessoa(Builder builder) { | |
this.nome = builder.nome; |
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
public class ExecutarPadraoBuilder { | |
public static void main(String[] args) { | |
Pessoa.Builder builder = new Pessoa.Builder(); | |
builder.setNome("Jefferson Tavares de Pádua") | |
.setCpf("111.111.111-11"); | |
Pessoa pessoa = builder.build(); | |
System.out.println(pessoa.getNome()); //O nome Jefferson Tavares de Pádua será mostrado na tela |
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
public interface ContratoBuilder<T> { | |
ContratoBuilder from(T object); | |
T build(); | |
} |
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
import java.util.Arrays; | |
import java.util.List; | |
public class Pessoa { | |
public List<Pensamento> pensar(boolean tempoLivre) { | |
if(tempoLivre) { | |
return Arrays.asList(new Pensamento("Livros"), new Pensamento("Estudos")); | |
}else { | |
return Arrays.asList(new Pensamento("Programação"), new Pensamento("Java")); | |
} |
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
import java.util.Arrays; | |
import java.util.List; | |
public class Pessoa { | |
public List<Pensamento> pensar(boolean tempoLivre) { | |
if(tempoLivre) { | |
return Arrays.asList(new Pensamento("Livros"), new Pensamento("Estudos")); | |
}else { | |
return Arrays.asList(new Pensamento("Programação"), new Pensamento("Java")); | |
} |
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
public class BungeeJumping { | |
public void executarSaltosDoDia(List<Pessoa> pessoas) { | |
for(Pessoa pessoa : pessoas) { | |
if (podeSaltar(pessoa)) { | |
System.out.println(pessoa.getGritoDeEmocao()); | |
} | |
} | |
} | |
private boolean podeSaltar(Pessoa pessoa) { |
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
public class BungeeJumping { | |
public void executarSaltosDoDia(List<Pessoa> pessoas) { | |
for(Pessoa pessoa : pessoas) { | |
try { | |
if (podeSaltar(pessoa)) { | |
System.out.println(pessoa.getGritoDeEmocao()); | |
} | |
} catch (IllegalArgumentException e) { | |
System.out.println(pessoa.getNome() + " não pode saltar por ter mais de 60 anos."); | |
} |
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
class HelloWorld { | |
public static void main(String[] args) { | |
System.out.println("Hello World!"); | |
} | |
} |
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
class HelloWorld { | |
public static void main(String[] args) { | |
System.out.println("Hello World!"); | |
} | |
} |
OlderNewer