Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WONT COMPILE HAVE STRAY / IN TEXT.H FAULTS AND MAIN FUNCTION FAULTS NOT DECLARES IN MOVIE.CPP GOT A DRIVER I WILL PAST AT THE BOTTOM

WONT COMPILE HAVE STRAY / IN TEXT.H FAULTS AND MAIN FUNCTION FAULTS NOT DECLARES IN MOVIE.CPP GOT A DRIVER I WILL PAST AT THE BOTTOM PLEASE HELP

#ifndef TEXT_H

#define TEXT_H

#include #include #include using namespace std;

struct Text { const char* textArray; int textLength; }

/* Function Name: createText() Parameters: Send a pointer to a constant character array or a string literal to this function Returns: A pointer to a new Text variable, which contains the c-string & the length of the string Purpose: To create a new Text variable */ Text* createText(const char*);

/* Function Name: destroyText() Parameters: Send a pointer to a Text variable, which contains a c-string & length of the string Returns: nothing (void) Purpose: release dynamically allocated memory that the pointer is pointing to. */ void destroyText(Text*);

/* Function Name: displayText() Parameters: Send a pointer to a Text variable, which contains a c-string & length of the string Returns: nothing (void) Purpose: prints out the string (character array) */ void displayText(Text*);

/* Function Name: getText() Parameters: Send a pointer to a Text variable, which contains a c-string & length of the string Returns: pointer to a constant character array */ const char* getText(Text*);

/* Function Name: getLength() Parameters: Send a pointer to a Text variable, which contains a c-string & length of the string Returns: the length of the string */ int getLength(Text*);

#endif

MOVIE.H

#ifndef MOVIE_H #define MOVIE_H #include "Text.h" #include #include #include #include using namespace std; class Movie { private: 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 public: /* 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(); /* 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(); /* 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(); /* 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(ofstream &outFile); void printMovieDetailsToFile(ofstream &outFile); void setMovieNumStars(float stars); void setMovieOscars(int oscars); void setMovieRating(Text *rating); void setMovieGenre(Text *genre); void setMovieYear(int year); void setMovieLength(int length); void setMovieTitle(Text *title); float getMovieNumStars(); int getMovieOscars(); Text getMovieRating(); Text * getMovieGenre(); Text *getMovieTitle(); int getMovieLength(); int getMovieYear(); }; #endif

MOVIE.CPP

#include #include #include #include #include "Movie.h" #include "Text.h" using namespace std; Movie *Movie::createMovie(Text *title, int length) { //dynamically allocate a new Movie Movie *myMovie = new Movie; //assign parameter data to structure members myMovie->movieTitle = title; myMovie->movieLength = length; return myMovie; } Movie *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 Movie::destroyMovie() { destroyText(movieTitle); destroyText(movieGenre); destroyText(movieRating); } void Movie::printMovieDetails() { cout << endl; cout << right << setw(30) << "Movie Title: " << left; displayText(movieTitle); cout << endl; cout << right << setw(30) << "Length (minutes): " << left << movieLength << endl; cout << right << setw(30) << "Year Released: " << left << movieYear << endl; cout << right << setw(30) << "Genre: " << left; displayText(movieGenre); cout << endl; cout << right << setw(30) << "Rating: " << left; displayText(movieRating); cout << endl; cout << right << setw(30) << "Number of Oscars Won: " << left << movieOscars << endl; cout << right << setw(30) << "Number of Stars: " << left << movieNumStars << endl << endl; } void Movie::printMovieDetailsToFile(ofstream &outFile) { char temp[1000]; strncpy(temp, getText(movieTitle), 1000); outFile << temp << endl; outFile << movieLength << endl; outFile << movieYear << endl; strncpy(temp, getText(movieGenre), 1000); outFile << temp << endl; strncpy(temp, getText(movieRating), 1000); outFile << temp << endl; outFile << movieOscars << endl; outFile << movieNumStars << endl; } void Movie::editMovie() { 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(movieTitle); destroyText(movieTitle); cout << " NEW TITLE: "; cin.getline(temp, 100); tempText = createText(temp); movieTitle = tempText; break; case 2: cout << " Current Length: " << movieLength; cout << " NEW LENGTH: "; cin >> movieLength; break; case 3: cout << " Current Year: " << movieYear; cout << " NEW LENGTH: "; cin >> movieYear; break; case 4: cout << " Current Genre: "; displayText(movieGenre); destroyText(movieGenre); cout << " NEW GENRE: "; cin.getline(temp, 100); tempText = createText(temp); movieGenre = tempText; break; case 5: cout << " Current Rating: "; displayText(movieRating); destroyText(movieRating); cout << " NEW GENRE: "; cin.getline(temp, 100); tempText = createText(temp); movieRating = tempText; break; case 6: cout << " Current Number of Oscars Won: " << movieOscars; cout << " NEW NUMBER OF OSCARS: "; cin >> movieOscars; break; case 7: cout << " Current Star Rating from IMDB: " << movieNumStars; cout << " NEW STAR RATING: "; cin >> movieNumStars; break; } } while (choice != 8); } Text *Movie::getMovieTitle() { return movieTitle; } int Movie::getMovieLength() { return movieLength; } int Movie::getMovieYear() { return movieYear; } Text Movie::*getMovieGenre() { return movieGenre; } Text Movie::*getMovieRating() { return this } int Movie::getMovieOscars() { return movieOscars; } float Movie::getMovieNumStars() { return movieNumStars; } void Movie::setMovieTitle(Text *title) { movieTitle = title; } void Movie::setMovieLength(int length) { movieLength = length; } void Movie::setMovieYear(int year) { movieYear = year; } void Movie::setMovieGenre(Text *genre) { movieGenre = genre; } void Movie::setMovieRating(Text *rating) { movieRating = rating; } void Movie::setMovieOscars(int oscars) { movieOscars = oscars; } void Movie::setMovieNumStars(float stars) { movieNumStars = stars; } DRIVER.CPP

#include "Movies.h" #include "Movie.h" #include "Text.h" #include using namespace std;

int main() { int menuChoice; int maxMovies; char filename[25]; cout << " What is the maximum number of movies you can have in your library? "; cin >> maxMovies; while(maxMovies <= 0) { cout << " You have to have at least one movie in your library. "; cout << "What is the maximum number of movies you can have in your library. "; cin >> maxMovies; } Movies* movieLibrary = createMovies(maxMovies); do { cout << " What would you like to do? "; cout << "1. Read movies from file. "; cout << "2. Save movies to a file. "; cout << "3. Add a movie. "; cout << "4. Delete a movie. "; cout << "5. Edit a movie. "; cout << "6. Print all movies. "; cout << "7. Delete ALL movies and end the program. "; cout << "CHOOSE 1-7: "; cin >> menuChoice; while(menuChoice < 1 || menuChoice > 7) { cout << "That is not a valid choice. "; cout << "CHOOSE 1-7: "; cin >> menuChoice; } switch(menuChoice) { case 1: cout << " What is the name of the file? (example.txt): "; cin >> filename; readMoviesFromFile(filename, movieLibrary); //function is in Movies.cpp break; case 2: cout << " What do you want to name the file? (example.txt): "; cin >> filename; saveToFile(filename, movieLibrary); //function is in Movies.cpp break; case 3: //add a movie addMovieToArray(movieLibrary); break; case 4: //remove a movie removeMovieFromArray(movieLibrary); break; case 5: //edit a movie editMovieInArray(movieLibrary); break; case 6: //print all movies displayMovies(movieLibrary); break; case 7: //delete all movies destroyMovies(movieLibrary); break; } } while(menuChoice != 7); cout << " GOODBYE! "; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions