Advertisement
Metaraddin

Untitled

Dec 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <vector>
  2. using namespace std;
  3.  
  4. class Word {
  5. private:
  6. string value;
  7. string font;
  8. int size;
  9.  
  10. public:
  11. Word() {}
  12. ~Word() {}
  13.  
  14. string getValue() { return value; }
  15. string getFont() { return font; }
  16. int getSize() { return size; }
  17.  
  18. void setValue(string valueInp) { value = valueInp; }
  19. void setFont(string fontInp) { font = fontInp; }
  20. void setSize(int sizeInp) {
  21. if (sizeInp < 1) { size = 1; }
  22. else if (sizeInp > 72) { size = 72; }
  23. else { size = sizeInp; }
  24. }
  25. };
  26.  
  27.  
  28. class Editor
  29. {
  30. private:
  31. vector <Word> mas;
  32. public:
  33. Editor() {}
  34. ~Editor() {}
  35.  
  36. bool insert(int ind, Word word) {
  37. if ((ind >= 0) && (ind < mas.size())) {
  38. mas.insert(mas.begin() + ind, word);
  39. return true;
  40. }
  41. return false;
  42. }
  43.  
  44. bool erase(int ind) {
  45. if ((ind >= 0) && (ind < mas.size())) {
  46. mas.erase(mas.begin() + ind);
  47. return true;
  48. }
  49. return false;
  50. }
  51.  
  52. void replace(string value, Word word) {
  53. for (int i = 0; i < mas.size(); i++) {
  54. if (mas.at(i).getValue() == value) {
  55. mas.at(i) = word;
  56. }
  57. }
  58. }
  59.  
  60. bool swap(int ind1, int ind2) {
  61. if ((ind1 >= 0) && (ind2 >= 0) && (ind1 < mas.size()) && (ind2 < mas.size())) {
  62. Word temp = mas.at(ind1);
  63. mas.at(ind1) = mas.at(ind2);
  64. mas.at(ind2) = temp;
  65. return true;
  66. }
  67. return false;
  68. }
  69.  
  70. bool setValue(int ind, string value) {
  71. if ((ind >= 0) && (ind < mas.size())) {
  72. mas.at(ind).setValue(value);
  73. return true;
  74. }
  75. return false;
  76. }
  77. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement