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
interface IComputadorBuilder { | |
setProcessador(processador: string): this; | |
setPlacaMae(placaMae: string): this; | |
setMemoriaRAM(memoriaRAM: string): this; | |
setArmazenamento(armazenamento: string): this; | |
setPlacaDeVideo(placaDeVideo: string): this; | |
setFonte(fonte: string): this; | |
setGabinete(gabinete: string): this; | |
setSistemaOperacional(sistemaOperacional: string): this; |
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
enum EstadoConta { | |
Ativa, | |
Bloqueada, | |
Inativa, | |
Suspensa, | |
Fechada | |
} | |
abstract class Estado { | |
abstract readonly estado: EstadoConta; |
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
enum TipoNotificacao { | |
ESTOQUE_BAIXO, | |
ESGOTADO | |
} | |
class Produto { | |
private quantidade: number; | |
constructor(quantidade: number){ | |
this.quantidade = quantidade; |
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 Article { | |
private observers: Observer[] = []; | |
addComment(comment: string): void{ | |
console.log("Comentário: ", comment); | |
this.notify(comment); | |
} | |
subscribe(observer: Observer): void{ |
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
abstract class Handler { | |
protected nextHandler?: Handler; | |
setNext(handler: Handler): Handler { | |
this.nextHandler = handler; | |
return handler; | |
} | |
handle(request: string): void { | |
if (this.nextHandler) { |
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
type Tamanho = 'PEQUENA' | 'MEDIA' | 'GRANDE'; | |
class Pizza { | |
protected tamanho!: Tamanho; | |
protected bordaRecheada: boolean = false; | |
protected sabores: string[] = []; | |
protected extras: string[] = []; | |
protected paraViagem: boolean = false; | |
private constructor() {} |
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 Formulario{ | |
email: string; | |
senha: string; | |
constructor(email: string, senha: string) { | |
this.email = email; | |
this.senha = senha; | |
} | |
validar(): void { | |
const validacao1 = new ValidacaoTamanhoSenha(); |
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
abstract class Aprovador{ | |
protected proximo: Aprovador | null = null; | |
// setando o proximo que vamos passar depois | |
setProximo(proximo: Aprovador): void{ | |
this.proximo = proximo; | |
} | |
abstract aprovar(valor: number): void; | |
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
abstract class Contato{ | |
nome: string; | |
constructor(nome: string){ | |
this.nome = nome; | |
} | |
adicionar(contato: Contato): void{ | |
throw new Error ("Esse componente não permite esse método"); | |
} |
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
// interface de implementação | |
interface Renderizador { | |
renderizarForma(forma: string): void; | |
} | |
// classes concretas | |
class RenderizadorWindows implements Renderizador { | |
renderizarForma(forma: string) { console.log(`Windows renderizando ${forma}`); } | |
} |
NewerOlder