Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef RESOURCE_H
- #define RESOURCE_H
- #include <ostream>
- #include <string>
- #include <sstream>
- #include "ResourceType.h"
- using namespace std;
- namespace SoftUni
- {
- class Resource
- {
- private:
- int id{ };
- ResourceType type{ };
- string link;
- public:
- Resource() = default;
- ResourceType getType() const
- {
- return this->type;
- }
- bool operator<(const Resource& other) const
- {
- return this->id < other.id;
- }
- friend ostream& operator<<(ostream& outStream, const Resource& resource);
- friend istream& operator>>(istream& inStream, Resource& resource);
- };
- ostream& operator<<(ostream& outStream, const Resource& resource)
- {
- return outStream << resource.id << " " << resource.type << " " << resource.link;
- }
- istream& operator>>(istream& inStream, ResourceType& resourceType)
- {
- string type;
- inStream >> type;
- if(type == "Presentation")
- resourceType = ResourceType::PRESENTATION;
- else if(type == "Demo")
- resourceType = ResourceType::DEMO;
- else if(type == "Video")
- resourceType = ResourceType::VIDEO;
- return inStream;
- }
- istream& operator>>(istream& inStream, Resource& resource)
- {
- return inStream >> resource.id >> resource.type >> resource.link;
- }
- }
- #endif // !RESOURCE_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement