Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Resources: \"Challenge: Ask For a User\'s Favorite Movies\" in Lesson 4, \"Class

ID: 3732354 • Letter: R

Question

Resources:

"Challenge: Ask For a User's Favorite Movies" in Lesson 4, "Classes and Objects," of the Lynda.com® course Learning C++ with Peggy Fisher

"Solution: Ask For a User's Favorite Movies" in Lesson 4, "Classes and Objects," of the Lynda.com® course Learning C++ with Peggy Fisher

Review the video "Challenge: Ask For a User's Favorite Movies" in Lesson 4, "Classes and Objects," of the Lynda.com® course Learning C++ with Peggy Fisher. Take notes on the program requirements.

Create a MyMovie class along with a main program that prompts a user with questions about his or her favorite movies, places the user's answers in an array, and then applies content from the array to the creation of MyMovie objects. Create a single C++ project (favoriteMovies) containing three interrelated files (favoriteMovies.cpp, Movie.cpp, and Movie.h) as follows:

Create a new project In Visual Studio® named favoriteMovies.

Type in the code for favoriteMovies.cpp. You may begin with the example favoriteMovies.cpp file located in Lynda.com® example, if you like.

From the Visual Studio® main menu, choose Project > Add Class, then choose Visual C++ and click the Add button.

Explanation / Answer

Below is the code, keep the classes in respective .cpp files.

class Movie

{

String title;

public:

Movie(String Title)

{

title = Title;

}

void displayMovieInfo()

{

cout << title;

}

}

class FavMovieClass

{

std::vector<Movie> fav_movies;

public:

void addMovieToLibrary()

{

string title;

cout << "Enter your favourite movie:";

cin >> title;

fav_movies.push_back(new Movie(title));

}

void displayFavouriteMovies()

{

cout << "My Favourite Movies list";

if (fav_movies.size() == 0) {

cout << "No movies in the list";

}

else {

for (auto movie : fav_movies) {

movie.displayMovieInfo();

}

}

}

}

int main() {

// Declare an object of class Fav movies

FavMovieClass mv;

mv.addMovieToLibrary();

mv.addMovieToLibrary();

mv.addMovieToLibrary();

mv.displayFavourieMovies();

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote