#include <iostream>
#include <memory>
#include <stdexcept>

class Resource {
public:
    Resource(const std::string& str): str_(str) {}

    const std::string& str() const {
        return str_;
    }

private:
    std::string str_;
};

class Converter {
public:
    virtual void Convert(const Resource& resource) = 0;
};

class CurlyBracketConverter : public Converter {
public:
    virtual void Convert(const Resource& resource) {
        std::cout << "{" << resource.str() << "}\n";
    }
};

class SquareBracketConverter : public Converter {
public:
    virtual void Convert(const Resource& resource) {
        std::cout << "[" << resource.str() << "]\n";
    }
};

class Printer {
public:
    Printer(Converter* converter): converter_(converter) {}

    void Print(const Resource& resource) {
        converter_->Convert(resource);
    }

private:
    Converter* converter_;
};

int main() {
    auto resource = std::make_unique<Resource>("Ala has a cat");
    Printer printer(new SquareBracketConverter{});
    Printer printer2(new CurlyBracketConverter{});

    printer.Print(*resource);
    printer2.Print(*resource);

    return 0;
}
