Created
January 12, 2011 19:12
-
-
Save AlfredoCasado/776679 to your computer and use it in GitHub Desktop.
Ejemplo dobles, clase compra
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 class Compra { | |
private final List<Producto> productos = new ArrayList(); | |
private final PasarelaDePago pasarelaDePago; | |
public Compra(PasarelaDePago pasarelaDePagoStub) { | |
this.pasarelaDePago = pasarelaDePagoStub; | |
} | |
public void anadir(Producto producto) { | |
productos.add(producto); | |
} | |
public int precio() { | |
int precioTotalCompra = 0; | |
for (Producto producto : productos) { | |
precioTotalCompra+=producto.precio(); | |
} | |
return precioTotalCompra; | |
} | |
boolean confirmar() { | |
return pasarelaDePago.tieneElUsuarioFondosPorValorDe(precio()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment