Guest User

Untitled

a guest
Oct 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. //
  2. // Created by Filip Staniul on 20/10/2018.
  3. //
  4.  
  5. #include <string>
  6. #include <vector>
  7.  
  8. class MenuItem {
  9. public:
  10. MenuItem(std::string name, std::string command);
  11. MenuItem(const MenuItem &cMenuItem);
  12. virtual ~MenuItem();
  13.  
  14. virtual void Run() = 0;
  15. virtual MenuItem *Clone() = 0;
  16.  
  17. std::string GetName();
  18. std::string GetCommand();
  19.  
  20. protected:
  21. std::string _name;
  22. std::string _command;
  23. };
  24.  
  25. class Menu : public MenuItem {
  26. public:
  27. Menu (std::string name, std::string command);
  28. Menu (std::string name, std::string command, std::vector<MenuItem *> &cMenuItems);
  29. Menu (const Menu &cMenu);
  30. ~Menu();
  31.  
  32. void Run();
  33. MenuItem *Clone();
  34.  
  35. bool AddMenuItem(MenuItem *item);
  36. bool RemoveMenuItem (std::string name);
  37. bool RemoveMenuItem (int index);
  38. std::vector<MenuItem *> *GetMenuItems();
  39. private:
  40. MenuItem *GetItemForCommand(std::string &command);
  41. void PrintInfo();
  42. void CopyMenuItems(const std::vector<MenuItem *> &cMenuItems);
  43.  
  44. std::vector<MenuItem*> _cMenuItems;
  45. };
  46.  
  47. class MenuCommand: public MenuItem {
  48. public:
  49. MenuCommand(std::string name, std::string command);
  50. MenuCommand(std::string name, std::string command, Command *cCommand);
  51. ~MenuCommand();
  52.  
  53. void AttachCommand (Command * cCommand);
  54.  
  55. void Run();
  56. MenuItem * Clone();
  57. private:
  58. Command * _cCommand;
  59. };
Add Comment
Please, Sign In to add comment