Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ /*Make code that will output the title of every movie. Also, list the name of every actor in that movie. The output should appear

C++

/*Make code that will output the title of every movie. Also, list the name of every actor in that movie. The output should appear something like:

Movie Name 1

Actor name 1

Actor name 2

Movie Name 2

No Actors

Movie Name 3

Actor name 1

Note the output when the movie has no actors.*/

#include #include #include using namespace std; class Actor { public: string actName; bool living; double salLastYear; }; class Movie { public: int leadActorIdx; int yrReleased; string title; vector* actors; Movie() :actors(NULL), yrReleased(0), leadActorIdx(-1) {} }; // Function to get Movies vector* getShows() { vector* ms = new vector; Movie *m = new Movie; m[0].title = "Star Wars"; m[0].yrReleased = 1976; m[0].leadActorIdx = 0; Actor* a = new Actor; m[0].actors = new vector; m[0].actors[0].push_back(a); a[0].actName = "Mark H."; a[0].salLastYear = 773612.98; a[0].living = true; ms[0].push_back(m); a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Carrie F."; a[0].salLastYear = 3616.9; a[0].living = false; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Harrison F."; a[0].salLastYear = 4713616.9; a[0].living = true; m = new Movie; m[0].actors = new vector; ms[0].push_back(m); m[0].title = "Midnite Run"; m[0].yrReleased = 1991; m[0].leadActorIdx = 1; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Charles G."; a[0].salLastYear = 36616.19; a[0].living = true; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Bobby D."; a[0].salLastYear = 2336616.19; a[0].living = true; m = new Movie; ms[0].push_back(m); m[0].title = "Life on the Serengheti"; m[0].yrReleased = 2002; m = new Movie; m[0].actors = new vector; ms[0].push_back(m); m[0].title = "Othello"; m[0].yrReleased = 1952; m[0].leadActorIdx = 1; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Dick B."; a[0].salLastYear = 0; a[0].living = false; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Liz T."; a[0].salLastYear = 20.01; a[0].living = false; m = new Movie; ms[0].push_back(m); m[0].title = "No Man Show"; m[0].yrReleased = 2018; m = new Movie; m[0].actors = new vector; ms[0].push_back(m); m[0].title = "1 woman show"; m[0].yrReleased = 2018; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Bea B."; a[0].salLastYear = 299310.01; a[0].living = true; m[0].leadActorIdx = 0; m = new Movie; m[0].actors = new vector; ms[0].push_back(m); m[0].title = "Ironman"; m[0].yrReleased = 2010; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Don C."; a[0].salLastYear = 1291119.01; a[0].living = true; m[0].leadActorIdx = 1; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Downey Jr."; a[0].salLastYear = 10291119; a[0].living = true; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "Gweneth P."; a[0].salLastYear = 391220; a[0].living = true; m = new Movie; m[0].actors = new vector; ms[0].push_back(m); m[0].title = "Disorderlies"; m[0].yrReleased = 1990; a = new Actor; m[0].actors[0].push_back(a); a[0].actName = "The Fatboys"; a[0].salLastYear = 20119.39; a[0].living = true; m[0].leadActorIdx = 0; m = new Movie; m[0].actors = new vector; ms[0].push_back(m); m[0].title = "Mortal Kombat"; m[0].yrReleased = 2014; return ms; } int main() {

vector *m; for (int i = 0; i < m->size(); i++) { cout << m->title; if (m->at(i)->actors) { cout << "Actor name" << Actor[]->actName; else(m->Actor == NULL) { cout << "There are no actors in this movie." << endl; } } } system("pause"); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions