Guest User

Resource.h

a guest
Dec 26th, 2019
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #ifndef RESOURCE_H_INCLUDED
  2. #define RESOURCE_H_INCLUDED
  3. #include <string>
  4. #include <iostream>
  5.  
  6. namespace SoftUni{
  7.  
  8. class Resource {
  9. int id;
  10. ResourceType type;
  11. std::string link;
  12. public:
  13. Resource(){
  14. this->id = 0;
  15. }
  16.  
  17. friend std::istream& operator >> (std::istream& in , Resource & object);
  18. friend std::ostream& operator << (std::ostream& out ,const Resource & object);
  19. friend bool operator < (const Resource& left, const Resource& right);
  20.  
  21. int getId() const {
  22. return this->id;
  23. }
  24. std::string getLink() const {
  25. return this->link;
  26. }
  27. ResourceType getType() const {
  28. return this->type;
  29.  
  30. }
  31.  
  32. };
  33. std::istream& operator >> (std::istream& in , Resource& object){
  34. std::string type;
  35. in>>object.id>>type>>object.link;
  36. if(type == "Presentation"){
  37. object.type = PRESENTATION;
  38. }
  39. else if(type == "Demo"){
  40. object.type = DEMO;
  41. }
  42. else {
  43. object.type = VIDEO;
  44. }
  45. return in;
  46. }
  47.  
  48. std::ostream& operator<< (std::ostream& out, const Resource& p){
  49. return out<<p.getId()<<" " << p.getType()<<" "<< p.getLink();
  50.  
  51. }
  52.  
  53. bool operator < (const Resource& left, const Resource& right){
  54. return left.getId()<right.getId();
  55. }
  56. }
  57.  
  58. #endif // RESOURCE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment