Created
October 21, 2014 12:18
-
-
Save mariofts/ce3eaf4c9a11f1ebcc2f to your computer and use it in GitHub Desktop.
ContaBuilder Alternativo
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
package br.com.caelum.fj91.banco.modelo; | |
import java.math.BigDecimal; | |
public interface Builder{ | |
Builder comLimite(BigDecimal limite); | |
Builder comTitular(Cliente titular); | |
Conta cria(); | |
} |
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
package br.com.caelum.fj91.banco.modelo; | |
import java.math.BigDecimal; | |
import java.util.Calendar; | |
public class ContaBuilder2 implements Numero, Data, Builder{ | |
private Conta c; | |
private int numero; | |
private Calendar dataAbertura; | |
private ContaBuilder2(){} | |
@Override | |
public Builder comLimite(BigDecimal limite) { | |
c.setLimite(limite); | |
return this; | |
} | |
@Override | |
public Builder comTitular(Cliente titular) { | |
c.setTitular(titular); | |
return this; | |
} | |
@Override | |
public Data comNumero(int numero){ | |
this.numero = numero; | |
return this; | |
} | |
@Override | |
public Builder comData(Calendar dataAbertura){ | |
this.dataAbertura = dataAbertura; | |
this.c = new Conta(numero,this.dataAbertura); | |
return this; | |
} | |
@Override | |
public Conta cria() { | |
return c; | |
} | |
public static Numero novaConta() { | |
return new ContaBuilder2(); | |
} | |
} |
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
package br.com.caelum.fj91.banco.modelo; | |
import java.util.Calendar; | |
public interface Data{ | |
Builder comData(Calendar data); | |
} |
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
package br.com.caelum.fj91.banco.modelo; | |
public interface Numero{ | |
Data comNumero(int numero); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment