Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need a text.h file and text.cpp file for this structure program converted into c

ID: 3746363 • Letter: N

Question


Need a text.h file and text.cpp file for this structure program converted into class progam title movie.h and movie. cpp

here is the structure .h file

*/
#ifndef MOVIE_H
#define MOVIE_H

#include "Text.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
using namespace std;

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;

.

Explanation / Answer

Movie.h

#ifndef MOVIE_H

#define MOVIE_H

#include "Text.h"

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cstring>

using namespace std;

class 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();

/*

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);

};

#endif

Movie.cpp

#include "Movie.h"

#include "Text.h"

Movie *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 *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);

delete myMovie;

}

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 movieRating;

}

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;

}

Let me know if you have any clarifications, Thank you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote