//Nullify the variables
MovieData::MovieData()
{
title = "";
director = "";
year = 0;
time = 0;
}
void MovieData::setTitle(string Title)
{
title = Title;
}
void MovieData::setDirector(string Director)
{
director = Director;
}
void MovieData::setYear(int Year)
{
if (Year >= 1900 && Year <= 2004)
{
year = Year;
}
else
{
cout << "The year must be between 1900 and 2004." << endl;
year = 0;
}
}
void MovieData::setTime(int Time)
{
if (Time >= 0 && Time <= 14400)
{
time = Time;
}
if (Time < 0)
{
cout << "The time cannot be negative. Please enter a positive number"
<< endl;
time = 0;
}
}
cout << "The title of the Movie is: " << getMovie.getTitle() << endl;
cout << "The Director's name is: " << getMovie.getDirector() << endl;
cout << "The year it was released was: " << getMovie.getYear() << endl;
cout << "The amount of minute the movie lasted was: "
<< getMovie.getTime() << endl;
return 0;
}
My output is:
Please enter the Title of the movie.
booby butt
Please enter the Director's name.
stupid noob
Please enter the year it was released.
1930
Please enter the amount of minutes the movie takes.
1337
The title of the Movie is:
The Director's name is:
The year it was released was: 0
The amount of minute the movie lasted was: 0
Process returned 0 (0x0) execution time : 24.037 s
Press any key to continue.
setMovie.setTitle(Title);
setMovie.setDirector(Director);
setMovie.setYear(Year);
setMovie.setTime(Time);
cout << "The title of the Movie is: " << getMovie.getTitle() << endl;
cout << "The Director's name is: " << getMovie.getDirector() << endl;
cout << "The year it was released was: " << getMovie.getYear() << endl;
cout << "The amount of minute the movie lasted was: "
<< getMovie.getTime() << endl;
You set the values for your setMovie object, but then you print the values of getMovie.
Please enter the Title of the movie.
booby butt
Please enter the Director's name.
stupid noob
Please enter the year it was released.
1930
Please enter the amount of minutes the movie takes.
1337