Question: Need a text.h file and text.cpp file for this structure program converted into class progam title movie.h and movie. cpp in the coverted h file
Need a text.h file and text.cpp file for this structure program converted into class progam title movie.h and movie. cpp
in the coverted h file class need a public accesor and private as well
here is the structure .h file
*/ #ifndef MOVIE_H #define MOVIE_H
#include "Text.h" #include
struct Movie { Text* movieTitle; //title of movie int movieLength; //length of movie in minutes int movieYear; //year released Text* movieGenre; //comedy, horror, sci-fi, fantasy, romance, thriller, drama, action, biography Text* movieRating; //G, PG, PG-13, R, MA int movieOscars; //number of oscars won float movieNumStars; //taken from IMDB on 10 star scale };
/* Function name: createMovie (overloaded function) Parameters: 1) A pointer to a Text variable, containing a c-string and the length of the string. 2) An integer containing the length of the movie Returns: A pointer to a new Movie structure Purpose: This function should be called when only the title of the movie and the length of the movie is known and it will create a new movie with this information. */ Movie* createMovie(Text*, int);
/* Function name: createMovie (overloaded function) Parameters: 1) A pointer to a Text variable, containing the title of the movie 2) An integer containing the length of the movie 3) An integer containing the year the movie was released 4) A pointer to a Text variable, containing the genre of the movie 5) A pointer to a Text variable, containing the rating of the movie 6) An integer containing the number of oscars the movie won 7) A float containing the IMDB rating of the movie (out of 10 stars) Returns: A pointer to a new Movie structure Purpose: This function should be called when all movie information is known and it will create a new movie with this information. */ Movie* createMovie(Text*, int, int, Text*, Text*, int, float);
/* Function name: editMovie Parameters: A pointer to a movie structure Returns: nothing (void) Purpose: This function should be called when the user wants to edit a single movie's data */ void editMovie(Movie* myMovie);
/* Function name: destroyMovie Parameters: A pointer to a movie structure Returns: nothing (void) Purpose: This function should be called when there is no longer need for the movie in the database (like when removing or deleting a movie). */ void destroyMovie(Movie*);
/* Function name: printMovieDetails Parameters: A pointer to a movie structure Returns: nothing (void) Purpose: This function should be called when the user wants to print ALL the movie information to the screen. */ void printMovieDetails(Movie*);
/* Function name: printMovieDetailsToFile Parameters: A pointer to a movie structure, a file stream object (sent by reference) Returns: nothing (void) Purpose: This function should be called when the user wants to print ALL the movie information to the file. */ void printMovieDetailsToFile(Movie* myMovie, ofstream& outFile);
#endif
heres he structure cpp file
#include "Movie.h" #include "Text.h"
Movie* createMovie(Text* title, int length) { //dynamically allocate a new Movie Movie* myMovie = new Movie; //assign parameter data to structure memebers myMovie->movieTitle = title; myMovie->movieLength = length; return myMovie; }
Movie* createMovie(Text* title, int length, int year, Text* genre, Text* rating, int nom, float stars) //all info is know { //dynamically allocate a new Movie Movie* myMovie = new Movie; //assign parameter data to structure members myMovie->movieTitle = title; myMovie->movieLength = length; myMovie->movieYear = year; myMovie->movieGenre = genre; myMovie->movieRating = rating; myMovie->movieOscars = nom; myMovie->movieNumStars = stars; return myMovie; } void destroyMovie(Movie* myMovie) { destroyText(myMovie->movieTitle); destroyText(myMovie->movieGenre); destroyText(myMovie->movieRating); delete myMovie; }
void printMovieDetails(Movie* myMovie) { cout << endl; cout << right << setw(30) << "Movie Title: "<< left; displayText(myMovie->movieTitle); cout << endl; cout << right << setw(30) << "Length (minutes): "<< left << myMovie->movieLength << endl; cout << right << setw(30) << "Year Released: "<< left << myMovie->movieYear << endl; cout << right << setw(30) << "Genre: " << left; displayText(myMovie->movieGenre); cout << endl; cout << right << setw(30) << "Rating: " << left; displayText(myMovie->movieRating); cout << endl; cout << right << setw(30) << "Number of Oscars Won: " << left << myMovie->movieOscars << endl; cout << right << setw(30) << "Number of Stars: "<< left << myMovie->movieNumStars << endl<< endl; }
void printMovieDetailsToFile(Movie* myMovie, ofstream& outFile) { char temp[1000]; strncpy(temp, getText(myMovie->movieTitle), 1000); outFile << temp << endl; outFile << myMovie->movieLength << endl; outFile << myMovie->movieYear << endl; strncpy(temp, getText(myMovie->movieGenre), 1000); outFile << temp << endl; strncpy(temp, getText(myMovie->movieRating), 1000); outFile << temp << endl; outFile << myMovie->movieOscars << endl; outFile << myMovie->movieNumStars << endl; }
void editMovie(Movie* myMovie) { int choice; Text* tempText; char temp[100]; do { cout << " Which detail do you wish to edit? "; cout << "1. Title "; cout << "2. Length "; cout << "3. Year "; cout << "4. Genre "; cout << "5. Rating "; cout << "6. Number of Oscars Won "; cout << "7. Number of Stars "; cout << "8. DONE EDITING "; cout << "CHOOSE 1-8: "; cin >> choice; while(choice < 1 || choice > 8) { cout << " OOPS! Enter choice 1 through 8: "; cin >> choice; } cin.ignore(); switch(choice) { case 1: cout << " Current Title: "; displayText(myMovie->movieTitle); destroyText(myMovie->movieTitle); cout << " NEW TITLE: "; cin.getline(temp, 100); tempText = createText(temp); myMovie->movieTitle = tempText; break; case 2: cout << " Current Length: "<< myMovie->movieLength; cout << " NEW LENGTH: "; cin >> myMovie->movieLength; break; case 3: cout << " Current Year: " << myMovie->movieYear; cout << " NEW LENGTH: "; cin >> myMovie->movieYear; break; case 4: cout << " Current Genre: "; displayText(myMovie->movieGenre); destroyText(myMovie->movieGenre); cout << " NEW GENRE: "; cin.getline(temp, 100); tempText = createText(temp); myMovie->movieGenre = tempText; break; case 5: cout << " Current Rating: "; displayText(myMovie->movieRating); destroyText(myMovie->movieRating); cout << " NEW GENRE: "; cin.getline(temp, 100); tempText = createText(temp); myMovie->movieRating = tempText; break; case 6: cout << " Current Number of Oscars Won: " << myMovie->movieOscars; cout << " NEW NUMBER OF OSCARS: "; cin >> myMovie->movieOscars; break; case 7: cout << " Current Star Rating from IMDB: " << myMovie->movieNumStars; cout << " NEW STAR RATING: "; cin >> myMovie->movieNumStars; break; } }while(choice != 8); }
Text* getMovieTitle(Movie* myMovie) { return myMovie->movieTitle; }
int getMovieLength(Movie* myMovie) { return myMovie->movieLength; }
int getMovieYear(Movie* myMovie) { return myMovie->movieYear; }
Text* getMovieGenre(Movie* myMovie) { return myMovie->movieGenre; }
Text* getMovieRating(Movie* myMovie) { return myMovie->movieRating; }
int getMovieOscars(Movie* myMovie) { return myMovie->movieOscars; }
float getMovieNumStars(Movie* myMovie) { return myMovie->movieNumStars; }
void setMovieTitle(Movie* myMovie, Text* title) { myMovie->movieTitle = title; }
void setMovieLength(Movie* myMovie, int length) { myMovie->movieLength = length; }
void setMovieYear(Movie* myMovie, int year) { myMovie->movieYear = year; }
void setMovieGenre(Movie* myMovie, Text* genre) { myMovie->movieGenre = genre; }
void setMovieRating(Movie* myMovie, Text* rating) { myMovie->movieRating = rating; }
void setMovieOscars(Movie* myMovie, int oscars) { myMovie->movieOscars = oscars; }
void setMovieNumStars(Movie* myMovie, float stars) { myMovie->movieNumStars = stars;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
