Advertisement
Guest User

Film.h

a guest
Dec 13th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. #pragma once
  2.  
  3. #ifndef FILM_H
  4. #include <iostream>
  5. #include <fstream>
  6. #include <iomanip>
  7. #include <string>
  8. #include <set>
  9. #include <vector>
  10. using namespace std;
  11. class Film
  12. {
  13. private:
  14. string name_;
  15. string producer_;
  16. string writter_;
  17. string genre_;
  18. unsigned year_;
  19. public:
  20. Film() :
  21. name_(),
  22. producer_(),
  23. writter_(),
  24. genre_(),
  25. year_(0)
  26. {}
  27. Film(const string& name, const string& producer, const string& writter, const string& genre, const unsigned& year) :
  28. name_(name),
  29. producer_(producer),
  30. writter_(writter),
  31. genre_(genre),
  32. year_(year)
  33. {}
  34. Film(const Film& film) :
  35.  
  36. name_(film.name_),
  37. producer_(film.producer_),
  38. writter_(film.writter_),
  39. genre_(film.genre_),
  40. year_(film.year_)
  41. {}
  42. ~Film()
  43. {}
  44. // операторы присваивания
  45. Film& operator=(const Film& other) {
  46. name_ = other.name_;
  47. producer_ = other.producer_;
  48. writter_ = other.writter_;
  49. genre_ = other.genre_;
  50. year_ = other.year_;
  51. return *this;
  52.  
  53. }
  54. // гетеры
  55. const string& getName() const { return name_; }
  56. const string& getProducer() const { return producer_; }
  57. const string& getWritter() const { return writter_; }
  58. const string& getGenre() const { return genre_; }
  59. const unsigned& getYear() const { return year_; }
  60. // сеттеры
  61. void setName(const string& name) { name_ = name; }
  62. void setProducer(const string& producer) { producer_ = producer; }
  63. void setWritter(const string& writter) { writter_ = writter; }
  64. void setGenre(const string& genre) { genre_ = genre; }
  65. void setYear(unsigned year) { year_ = year; }
  66.  
  67.  
  68. // операторы отношения
  69. bool operator<(const Film& film) const {
  70. return year_ < film.year_;
  71. }
  72. bool operator>(const Film& film) const {
  73. return year_ > film.year_;
  74. }
  75. bool operator<=(const Film& film) const {
  76. return year_ <= film.year_;
  77. }
  78. bool operator>=(const Film& film) const {
  79. return year_ >= film.year_;
  80. }
  81. bool operator==(const Film& film) const {
  82. return year_ == film.year_;
  83. }
  84. bool operator!=(const Film& film) const {
  85. return year_ != film.year_;
  86. }
  87. // операторы инкремента и декремента
  88. Film& operator++()
  89. {
  90. ++year_;
  91. return *this;
  92. }
  93. Film& operator--()
  94. {
  95. --year_;
  96. return *this;
  97. }
  98. // операторы >> и <<
  99. friend istream& operator>>(istream& input, Film& film) {
  100. input >> film.name_ >> film.producer_ >> film.writter_ >> film.genre_ >> film.year_;
  101. return input;
  102. }
  103. friend ostream& operator<<(ostream& output, const Film& film) {
  104.  
  105. output << film.name_ << ' ' << film.producer_ << ' ' << film.writter_ << ' ' << film.genre_ << ' ' << film.year_;
  106. return output;
  107. }
  108. };
  109.  
  110. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement