Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #ifndef FILM_H
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- #include <set>
- #include <vector>
- using namespace std;
- class Film
- {
- private:
- string name_;
- string producer_;
- string writter_;
- string genre_;
- unsigned year_;
- public:
- Film() :
- name_(),
- producer_(),
- writter_(),
- genre_(),
- year_(0)
- {}
- Film(const string& name, const string& producer, const string& writter, const string& genre, const unsigned& year) :
- name_(name),
- producer_(producer),
- writter_(writter),
- genre_(genre),
- year_(year)
- {}
- Film(const Film& film) :
- name_(film.name_),
- producer_(film.producer_),
- writter_(film.writter_),
- genre_(film.genre_),
- year_(film.year_)
- {}
- ~Film()
- {}
- // операторы присваивания
- Film& operator=(const Film& other) {
- name_ = other.name_;
- producer_ = other.producer_;
- writter_ = other.writter_;
- genre_ = other.genre_;
- year_ = other.year_;
- return *this;
- }
- // гетеры
- const string& getName() const { return name_; }
- const string& getProducer() const { return producer_; }
- const string& getWritter() const { return writter_; }
- const string& getGenre() const { return genre_; }
- const unsigned& getYear() const { return year_; }
- // сеттеры
- void setName(const string& name) { name_ = name; }
- void setProducer(const string& producer) { producer_ = producer; }
- void setWritter(const string& writter) { writter_ = writter; }
- void setGenre(const string& genre) { genre_ = genre; }
- void setYear(unsigned year) { year_ = year; }
- // операторы отношения
- bool operator<(const Film& film) const {
- return year_ < film.year_;
- }
- bool operator>(const Film& film) const {
- return year_ > film.year_;
- }
- bool operator<=(const Film& film) const {
- return year_ <= film.year_;
- }
- bool operator>=(const Film& film) const {
- return year_ >= film.year_;
- }
- bool operator==(const Film& film) const {
- return year_ == film.year_;
- }
- bool operator!=(const Film& film) const {
- return year_ != film.year_;
- }
- // операторы инкремента и декремента
- Film& operator++()
- {
- ++year_;
- return *this;
- }
- Film& operator--()
- {
- --year_;
- return *this;
- }
- // операторы >> и <<
- friend istream& operator>>(istream& input, Film& film) {
- input >> film.name_ >> film.producer_ >> film.writter_ >> film.genre_ >> film.year_;
- return input;
- }
- friend ostream& operator<<(ostream& output, const Film& film) {
- output << film.name_ << ' ' << film.producer_ << ' ' << film.writter_ << ' ' << film.genre_ << ' ' << film.year_;
- return output;
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement