Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ShoppingCart implements EstadoOrder{
- private static final ShoppingCart instancia = new ShoppingCart();
- private ShoppingCart(){}
- public static ShoppingCart getInstancia(){ return instancia; }
- @Override
- public void anadirProducto(Order order, Product producto) {
- if(producto.getStock()>0) {
- order.getLista().add(producto);
- producto.setStock(producto.getStock()-1);
- }
- }
- @Override
- public void eliminarProducto(Order order, Product producto) {
- order.getLista().remove(producto);
- producto.setStock(producto.getStock()+1);
- }
- @Override
- public void siguienteEstado(Order order) {
- order.setEstado(CheckOut.getInstancia());
- }
- @Override
- public void anteriorEstado(Order order) {
- }
- @Override
- public void modificarCantidadProducto(Order order, Product producto) {
- }
- @Override
- public void pagar(Order order) {
- }
- @Override
- public void cancelar(Order order) {
- }
- @Override
- public void screenInfo(Order order) {
- System.out.println("Order number " + order.getOrdernumber() + "\n" + "Phase: Shopping -- Welcome to online shop\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement