Guest User

Untitled

a guest
Jan 4th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package miage.ecom.appclient.command;
  7.  
  8. import miage.ecom.cart.CartRemote;
  9. import miage.shell.Context;
  10. import miage.shell.command.CartCommand;
  11. import miage.shell.command.ContextualCommand;
  12. import miage.shell.command.option.OptionName;
  13.  
  14. /**
  15. *
  16. * @author mrabaris
  17. */
  18. public class CartCustomerShellCommand extends CartCommand implements ContextualCommand{
  19.  
  20. private final CartRemote cartRemote;
  21. private Context context;
  22.  
  23. public CartCustomerShellCommand(Context context, CartRemote cartRemote){
  24. super();
  25. this.cartRemote = cartRemote;
  26. this.context = context;
  27. }
  28.  
  29. @Override
  30. public void defaultAction(){
  31. super.defaultAction();
  32. for(String s : this.cartRemote.listContent()){
  33. this.getOut().println(s);
  34. }
  35. }
  36.  
  37.  
  38. @Override
  39. public void addAction(){
  40. super.addAction();
  41. this.cartRemote.addProduct(values.get(optionsByName.get(OptionName.ADD)));
  42. }
  43.  
  44. @Override
  45. public void removeAction(){
  46. super.removeAction();
  47. this.cartRemote.removeProduct(values.get(optionsByName.get(OptionName.REMOVE)));
  48. }
  49.  
  50. @Override
  51. public void buyAction(){
  52. super.buyAction();
  53. this.cartRemote.buyWith(values.get(optionsByName.get(OptionName.BUY)));
  54. }
  55.  
  56. @Override
  57. public Context getContext() {
  58. return context;
  59. }
  60.  
  61. @Override
  62. public void setContext(Context context) {
  63. this.context = context;
  64. }
  65.  
  66. }
Add Comment
Please, Sign In to add comment