Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- using namespace std;
- class Word {
- private:
- string value;
- string font;
- int size;
- public:
- Word() {}
- ~Word() {}
- string getValue() { return value; }
- string getFont() { return font; }
- int getSize() { return size; }
- void setValue(string valueInp) { value = valueInp; }
- void setFont(string fontInp) { font = fontInp; }
- void setSize(int sizeInp) {
- if (sizeInp < 1) { size = 1; }
- else if (sizeInp > 72) { size = 72; }
- else { size = sizeInp; }
- }
- };
- class Editor
- {
- private:
- vector <Word> mas;
- public:
- Editor() {}
- ~Editor() {}
- bool insert(int ind, Word word) {
- if ((ind >= 0) && (ind < mas.size())) {
- mas.insert(mas.begin() + ind, word);
- return true;
- }
- return false;
- }
- bool erase(int ind) {
- if ((ind >= 0) && (ind < mas.size())) {
- mas.erase(mas.begin() + ind);
- return true;
- }
- return false;
- }
- void replace(string value, Word word) {
- for (int i = 0; i < mas.size(); i++) {
- if (mas.at(i).getValue() == value) {
- mas.at(i) = word;
- }
- }
- }
- bool swap(int ind1, int ind2) {
- if ((ind1 >= 0) && (ind2 >= 0) && (ind1 < mas.size()) && (ind2 < mas.size())) {
- Word temp = mas.at(ind1);
- mas.at(ind1) = mas.at(ind2);
- mas.at(ind2) = temp;
- return true;
- }
- return false;
- }
- bool setValue(int ind, string value) {
- if ((ind >= 0) && (ind < mas.size())) {
- mas.at(ind).setValue(value);
- return true;
- }
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement