Skips a Step

#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

//Class function
class MovieData
{
private:
string title;
string director;
int year;
int time;

public:

MovieData(); //constructor
void setTitle(string Title);
void setDirector(string Director);
void setYear(int Year);
void setTime(int Time);
string getTitle();
string getDirector();
int getYear();
int getTime();

};

//Nullify the variables
MovieData::MovieData()
{
title = "";
director = "";
year = 0;
time = 0;
}

//Set the title of movie
void MovieData::setTitle(string Title)
{
title = Title;
}

//Set the name of director
void MovieData::setDirector(string Director)
{
director = Director;
}

//Set the year it was released
void MovieData::setYear(int Year)
{
year = Year;
}

//Set the amount of minute the movie took
void MovieData::setTime(int Time)
{
time = Time;
}

string MovieData::getTitle()
{
return title;
}

string MovieData::getDirector()
{
return director;
}

int MovieData::getYear()
{
return year;
}

int MovieData::getTime()
{
return time;
}

//Start of body
int main()
{
//MovieData Objects
MovieData movieInfo1;
MovieData movieInfo2;

string Title;
string Director;
int Year;
int Time;

//****************************~~FIRST~~*****************************************
//****************************~~MOVIE~~*****************************************

cout << "Please enter the Title of a movie." << endl;
getline(cin,Title);

cout << "Please enter the Director's name." << endl;
getline(cin,Director);

cout << "Please enter the year it was released." << endl;
cin >> Year;
//Checks to see if the year is valid
if(Year >= 1900 && Year <= 2004);
else {
Year = 0;
cout << "Please enter a number between 1900 and 2004." << endl;
return false;
}

cout << "Please enter the amount of minutes the movie takes." << endl;
cin >> Time;
//checks to see if the minute is correct
if (Time >= 0 && Time <= 14400);
else if(Time < 0) {
Time = 0;
cout << "Please enter a positive number, time cannot be negative."
<< endl;
return false;
} else
return false;

//Sets the private members
movieInfo1.setTitle(Title);
movieInfo1.setDirector(Director);
movieInfo1.setYear(Year);
movieInfo1.setTime(Time);

//***************************~~SECOND~~*****************************************
//****************************~~MOVIE~~*****************************************
//
cout << "Please enter the Title of another movie." << endl;
getline(cin,Title);

cout << "Please enter the Director's name." << endl;
getline(cin,Director);

cout << "Please enter the year it was released." << endl;
cin >> Year;
//Checks to see if the year is valid
if(Year >= 1900 && Year <= 2004);
else {
Year = 0;
cout << "Please enter a number between 1900 and 2004." << endl;
return false;
}

cout << "Please enter the amount of minutes the movie takes." << endl;
cin >> Time;
//checks to see if the minute is correct
if (Time >= 0 && Time <= 14400);
else if(Time < 0) {
Time = 0;
cout << "Please enter a positive number, time cannot be negative."
<< endl;
return false;
} else
return false;

//Sets the private members
movieInfo2.setTitle(Title);
movieInfo2.setDirector(Director);
movieInfo2.setYear(Year);
movieInfo2.setTime(Time);

//******************************************************************************
//******************************************************************************

cout << "The title of the first Movie is: " << movieInfo1.getTitle()
<< endl;
cout << "The Director's name is: " << movieInfo1.getDirector() << endl;
cout << "The year it was released was: " << movieInfo1.getYear() << endl;
cout << "The amount of minute the movie lasted was: "
<< movieInfo1.getTime() << endl;

cout << "\nThe title of the second Movie is: " << movieInfo2.getTitle()
<< endl;
cout << "The Director's name is: " << movieInfo2.getDirector() << endl;
cout << "The year it was released was: " << movieInfo2.getYear() << endl;
cout << "The amount of minute the movie lasted was: "
<< movieInfo2.getTime() << endl;

return 0;
}//end main



When i run it, it skips
"cout << "Please enter the Title of another movie." << endl;
getline(cin,Title); "
and goes straight into
cout << "Please enter the Director's name." << endl;

does anyone know the reason why?
Topic archived. No new replies allowed.