Question
LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT...

Answers
Hi,
please find the program below for movie and movieList,
As per HomeworkLib rules , i have answered all the first 6 subparts of the question a(i.e movie class).
Implemented MovieList class also.
kindly upvote
Please find output and program below.
#ifndef MOVIE_H
#define MOVIE_H#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>using namespace std;
class Movie
{
private:
std::string _title;
std::string _genre;
size_t _year;
public:
Movie(std::string &title, std::string &genre, size_t &year);
Movie(const Movie&);
~Movie()
{
std::cout << "\nDestructor called\n";
}
void write(ostream& output,bool = false);
void read(istream& input);
bool Equals(const Movie&);
void setMovieInfo(std::string &title, std::string &genre, size_t &description);
bool operator == (const Movie& otherPossibleMovie) ;
std::string getTitle() const;
std::string getGenre() const;
size_t getYear() const;
void printMovie();
};#endif
bool Movie::Equals(const Movie& otherMovie)
{
if(this == &otherMovie)
return true; //This is the pointer for
else
return false;
}void Movie::write(ostream& output,bool value)
{
if(value == true)
{
output << setw(30)<< _title << endl;
output << setw(15)<< _genre << endl;
output << setw(6)<< _year << endl;
}
else
{
output << _title << endl << _genre << endl << _year << endl;
}
}
std::string gulp(std::istream &in)
{
std::string ret;
char buffer[4096];
while (in.read(buffer, sizeof(buffer)))
ret.append(buffer, sizeof(buffer));
ret.append(buffer, in.gcount());
return ret;
}void Movie::read(istream& mystream)
{
gulp(mystream);
}
Movie::Movie(std::string &title, std::string& genre, size_t &year)
{
setMovieInfo(title, genre,year);
}
void Movie::printMovie()
{
std::cout << "Title: " << _title << '\n';
std::cout << "Genre" << _genre << '\n';
std::cout << "Year:" << _year << '\n';
}// Movie mem function
void Movie::setMovieInfo(std::string &title, std::string& genre, size_t &year)
{
_title= title;
_genre= genre;
_year= year;
}std::string Movie::getTitle() const
{
return _title;
}std::string Movie::getGenre() const
{
return _genre;
}size_t Movie::getYear() const
{
return _year;
}
bool Movie::operator == (const Movie& otherPossibleMovie)
{
if (this->getTitle() == otherPossibleMovie.getTitle() &&
this->getGenre() == otherPossibleMovie.getGenre() &&
this->getYear() == otherPossibleMovie.getYear())
return true;
else
return false;
}class MovieList {
public:
Movie* movies;
int last_movie_index = 1;
int movies_size = 20;
int movie_count = 0;
~MovieList() {
delete [] movies;
}int Length() {
return movie_count;
}bool IsFull()
{
if(movie_count = movies_size)
{
return true;
}
else
{
return false;
}
}void Add(Movie const& m)
{
cout << "coming to add function " << endl;
for(int i=0; i<30;i++)
{
movies[i]=m;
movie_count++;
break;
}
}void PrintAll() {
for (int i = 0; i < movie_count; i++) {
movies[i].printMovie();
}
}
};
int main()
{
MovieList *movies ;
std::string title;
size_t releaseYear;
std::string genre;title= "Aashique";
releaseYear= 1982;
genre= "action.";Movie letsc(title, genre, releaseYear);
letsc.printMovie();
//movies->Add(letsc);
//movies->PrintAll();
return 0;
}
![]()
Thanks,
kindly upvote
Title: Aashique Genreaction Year:1982 Destructor called