#ifndef RESOURCE_H #define RESOURCE_H #include #include #include #include "Operators.h" namespace SoftUni { class Resource { public: int id; std::string link, type; static std::vector x; static int element; friend bool operator<(Resource const& left, Resource const& right); ResourceType getType() const { return x[element++]; } friend std::istream& operator>>(std::istream& in, Resource& r); }; bool operator<(Resource const& left, Resource const& right) { return (left.id < right.id); } std::istream& operator>>(std::istream& in, SoftUni::Resource& r) { if (r.type == "PRESENTATION") { Resource::x.push_back(ResourceType::PRESENTATION); } else if (r.type == "Demo") { Resource::x.push_back(ResourceType::DEMO); } else { Resource::x.push_back(ResourceType::VIDEO); } return in >> r.id >> r.type >> r.link; } std::ostream& operator<<(std::ostream& out, Resource const& object) { return out << object.id << ' ' << Resource::x[Resource::element++] << ' ' << object.link << std::endl; } } #endif