Saturday, January 31, 2015

MovieData

The program should create two MovieData variables, store values in
their members, and pass each one, in turn, to a function that displays the
information about the movie in a clearly formatted manner


#include <iostream>
#include <string>

using namespace std;

struct MovieData
{
 string m, n, o, p;
 MovieData (string, string, string, string);
};
//Make a constructor
MovieData::MovieData (string a, string b, string c, string d) {
    m = a;
    n = b;
    o = c;
    p = d;
}

void printinfo (MovieData Q)
{
cout<<"Title:         "<<Q.m<<endl;
cout<<"Director:      "<<Q.n<<endl;
cout<<"Year Released: "<<Q.o<<endl;
cout<<"Writer:  "<<Q.p<<endl;
}

int main()
{
    string title;
string direct;
string yearR;
string writer;
//title
    std::cout << "Enter title of movie:\n";
    std::getline(std::cin, title);
//director
    std::cout << "Enter the Director of movie:\n";
    std::getline(std::cin, direct);
//year
    std::cout << "Enter the year movie was released:\n";
    std::getline(std::cin, yearR);
//writer
    std::cout << "Enter writer of the screenplay:\n";
    std::getline(std::cin, writer);

MovieData movie1(title, direct, yearR, writer);
    //=====================================================//
//title
    std::cout << "Enter title of movie:\n";
    std::getline(std::cin, title);
//director
    std::cout << "Enter the Director of movie:\n";
    std::getline(std::cin, direct);
//year
    std::cout << "Enter the year movie was released:\n";
    std::getline(std::cin, yearR);
//writer
    std::cout << "Enter writer of the screenplay:\n";
    std::getline(std::cin, writer);
MovieData movie2(title, direct, yearR, writer);
//i know this could be done in a loop...//
//===========================================================//

//Call function to Display the results.
    cout<<"\n\nHere is the Movie Data:\n";
    cout<<"Movie 1:";
    cout<<"\n-----------------------\n";

printinfo (movie1);
    cout<<"\n\nMovie 2:";
    cout<<"\n-----------------------\n";

printinfo (movie2);

return 0;
}