Skip to content

Instantly share code, notes, and snippets.

View walteralleyz's full-sized avatar
🚀
Flying like a Rocket!

WalterAlleyz walteralleyz

🚀
Flying like a Rocket!
View GitHub Profile
/*
Author: Walter Alleyz
Date: 2022-03-29
Objective: Show the main patterns widely used in the object oriented programming scenario.
Patterns: Strategy, Chain Of Resposability, Template Method, Observer, Adapter, Decorator, Composite, Proxy and Facade.
*/
import java.util.Optional;
class Main {
class RevistaInformatica extends Observable {
private int edicao;
public void setNovaEdicao(int novaEdicao) {
this.edicao = novaEdicao;
setChanged();
notifyObservers();
}
class No {
protected int chave;
No esquerdo, direito;
public No(int chave) {
this.chave = chave;
esquerdo = null;
direito = null;
}
class Numero implements Operador {
private int numero;
public Numero(int numero) {
this.numero = numero;
}
@Override
public int interpretar() {
interface Desconto {
BigDecimal calcular(Pedido pedido);
void setProximo(Desconto proximo);
}
class DescontoPorItens implements Desconto {
private Desconto proximo;
abstract class Command {
public Editor editor;
private String backup;
Command(Editor editor) {
this.editor = editor;
}
void backup() {
backup = editor.textField.getText();
class Editor extends JComponent {
private Canvas canvas;
private CompoundShape allShapes = new CompoundShape();
private History history;
public Editor() {
canvas = new Canvas(this);
history = new History();
}
interface ProfileIterator {
boolean hasNext();
Profile getNext();
void reset();
}
class FacebookIterator implements ProfileIterator {
private Facebook facebook;
interface Component {
void setMediator(Mediator mediator);
String getName();
}
class AddButton extends JButton implements Component {
private Mediator mediator;
public AddButton() {
super("Add");
abstract class State {
Player player;
/**
* Context passes itself through the state constructor. This may help a
* state to fetch some useful context data if needed.
*/
State(Player player) {
this.player = player;
}