1

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

Question

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

LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT List by creating a list of movie
LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT List by creating a list of movies. This assignment will help you practice: multiple file programming, classes, pablic and private methods, dynamie memory, constructors and destructors, arrays and files Implementation the required classes This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of There are two classes to implement: Movie and MovieList. As you can see in the description table, MovieList has_movies, a list of Movie objects modeled using an array of Movie (pointers to Movie). Each Movie object will be dynamically created when it is added to the list if it is possible to add them (the list might be full, or the insert position invalid). You will create the following files: contains the Movie class declaration contains the Movie class method definitions contains the Movie class declaration contains the Movie class method definitions movie, h - movie.cpp - movielist.h - movielist.cpp You are not turning in a main( for this program. You will compile, run, and test your program using the unit test. You are strongly encouraged to start by writing Movie and ensuring all relevant unit tests pass before moving on to MovieList. Only the unit test will be used for grading The following table explains each of the methods that you will need to implement. Class Access Member Description Private Private genre Private Title of the movie, there can be spaces in the title Genre of the movie, there can be spaces in the Year the movie was first released in theaters Constructor that takes in the title, the genre, year Public Movie const strings title, and the year for a movic. Notice that there is const string& genre, N0 default constructor ize t year Public Movie(const Movie&) PublicWrite( Copy constructor. Writes the movie to the output stream in the parameter. Prints a formatted output if the ostream&, bool false): void boo1 parameter is true (30 columns for title, Movie 15 for genre, 6 for year), prints unformatted output if the bool is false (one field per line). Reads a movie from an input stream, the fields Public Read(istrean&): void end line. Public Gettitle): string Public GetGenre): string Public GetYear(): size t Public Equals (const Movie&): bool Compares two movies for equality, returns true Returns the title of the movie. Returns the genre of the movie. Returns the year of the movie. if title, genre, and year match exactly, false otherwise.

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;
}

Title: Aashique Genreaction Year:1982 Destructor called

Thanks,

kindly upvote


Similar Solved Questions

1 answers
How does a production possibilities curve illustrate how efficient an economy is
How does a production possibilities curve illustrate how efficient an economy is?...
1 answers
Salud Company reports the following information. Selected Annual Income Statement Data Selected Year-End Balance Sheet Data...
Salud Company reports the following information. Selected Annual Income Statement Data Selected Year-End Balance Sheet Data Net income $ 495,000 Accounts receivable increase $ 43,200 Depreciation expense 94,000 Prepaid expenses decrease 16,200 Gain on sale of machinery 26,900 ...
1 answers
How do you write # (–3r + 4r^2 – 3) – (4r^2 + 6r – 2)# in standard form?
How do you write # (–3r + 4r^2 – 3) – (4r^2 + 6r – 2)# in standard form?...
1 answers
A simple ideal Brayton cycle operates with air with minimum and maximum temperatures of 27°C and...
A simple ideal Brayton cycle operates with air with minimum and maximum temperatures of 27°C and 727°C. It is designed so that the maximum cycle pressure is 2000 kPa and the minimum cycle pressure is 100 kPa. The isentropic efficiency of the turbine is 96 percent. Determine the net work prod...
1 answers
The pK, value for HF is 3.14. Would a buffer prepared from HF and NaF with...
The pK, value for HF is 3.14. Would a buffer prepared from HF and NaF with a pH of 5.14 be considered to be an effective buffer? A buffer in which the mole ratio of NaF to HF is 1.7 has a pH of 3.36. Would this buffer solution have a greater capacity for added acid (H307) or added base (OH)? added a...
1 answers
Rank in increasing order by placing the most negative on the left and the most positive...
Rank in increasing order by placing the most negative on the left and the most positive on the right. To rank items as equivalent, overlap them....
1 answers
Describe a common sexually-transmitted disease, including the transmission, symptoms, and pharmacological treatment of the condition. Discuss...
Describe a common sexually-transmitted disease, including the transmission, symptoms, and pharmacological treatment of the condition. Discuss the epidemiology and current trends in diagnosis and treatment of the disease you have chosen...
1 answers
Samples of fabric from a textile mill, each 100 m", are selected, and the number of...
Samples of fabric from a textile mill, each 100 m", are selected, and the number of occurrences of foreign matter is recorded. Data for 25 samples are shown in Table 8-9. Construct a c-chart for the number of nonconformities, Table 8-9 Foreign Matter Data Sample Nonconformities Sample Nonconform...
1 answers
Question 19 of 23 > A certain weak base has a Kb of 8.70 x 10-7....
Question 19 of 23 > A certain weak base has a Kb of 8.70 x 10-7. What concentration of this base will produce a pH of 10.12? concentration: M...
1 answers
CH2 KB. Which are the three product costs that are added to work in process? Direct...
CH2 KB. Which are the three product costs that are added to work in process? Direct labor, materials used in production, actual manufacturing overhead Direct materials, direct labor, materials used in production Direct materials, direct labor, applied manufacturing overhead Direct materials, direct ...
1 answers
You drop a 2.5 kg book, from rest, from a height of 7.5 m. A student...
You drop a 2.5 kg book, from rest, from a height of 7.5 m. A student receives it at a height of 0.8 m from the floor. If the zero potential energy reference level is the floor, the kinetic energy in the problem book just an instant before falling into the hand of the student who receives it below is...
1 answers
What diene and dienophile would react to give the product below? Draw the molecule on the...
What diene and dienophile would react to give the product below? Draw the molecule on the canvas by choosing buttons from the Tools...
1 answers
What is the cross product of #<2 , 5 ,-7 ># and #<5 ,6 ,-9 >#?
What is the cross product of #<2 , 5 ,-7 ># and #<5 ,6 ,-9 >#?...
1 answers
A particle is moving with acceleration a(t) 36t +16. its position at time t0 is s(0) 12 and its velocity at timet0 is (0)-1. What is its position at time t- 12? Preview A particle is moving with...
A particle is moving with acceleration a(t) 36t +16. its position at time t0 is s(0) 12 and its velocity at timet0 is (0)-1. What is its position at time t- 12? Preview A particle is moving with acceleration a(t) 36t +16. its position at time t0 is s(0) 12 and its velocity at timet0 is (0)-1. What ...
1 answers
Consider the following aldehydes and ketones. Which is the correct ranking in order of increasing reactivity...
Consider the following aldehydes and ketones. Which is the correct ranking in order of increasing reactivity towards nucleophilic addition to the carbonyl group? A) 2-methylcyclohexanone < cyclohexanone < CH3CHO < H2CO B) CH3CHO < 2-methylcyclohexanone < cyclohexanone < H2CO C) cyc...
1 answers
Which of the following is important for the design and use of a reporter GFP fusion...
Which of the following is important for the design and use of a reporter GFP fusion protein plasmid to study the subcellular localization of a protein of interest? Select all the apply. Question 9 options: the STOP codon from the gene of the protein of interest must be removed before insertion into ...
1 answers
1. Stratege Consulting owns a cellphone store where it buys and sells cellphones as the store's main business activ...
1. Stratege Consulting owns a cellphone store where it buys and sells cellphones as the store's main business activity. Below are Stratege Consulting LLC transactions for the month of March 2019. . . . . . 3/1 Began with 200 cellphones @ $50 in its inventory 3/10 Purchased 100 cellphones @ $40 3...

-- 0.012762--