Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package miage.ecom.appclient.command;
- import miage.ecom.cart.CartRemote;
- import miage.shell.Context;
- import miage.shell.command.CartCommand;
- import miage.shell.command.ContextualCommand;
- import miage.shell.command.option.OptionName;
- /**
- *
- * @author mrabaris
- */
- public class CartCustomerShellCommand extends CartCommand implements ContextualCommand{
- private final CartRemote cartRemote;
- private Context context;
- public CartCustomerShellCommand(Context context, CartRemote cartRemote){
- super();
- this.cartRemote = cartRemote;
- this.context = context;
- }
- @Override
- public void defaultAction(){
- super.defaultAction();
- for(String s : this.cartRemote.listContent()){
- this.getOut().println(s);
- }
- }
- @Override
- public void addAction(){
- super.addAction();
- this.cartRemote.addProduct(values.get(optionsByName.get(OptionName.ADD)));
- }
- @Override
- public void removeAction(){
- super.removeAction();
- this.cartRemote.removeProduct(values.get(optionsByName.get(OptionName.REMOVE)));
- }
- @Override
- public void buyAction(){
- super.buyAction();
- this.cartRemote.buyWith(values.get(optionsByName.get(OptionName.BUY)));
- }
- @Override
- public Context getContext() {
- return context;
- }
- @Override
- public void setContext(Context context) {
- this.context = context;
- }
- }
Add Comment
Please, Sign In to add comment