Could someone please help me with this C++ project, the instructions are below:
ID: 3741967 • Letter: C
Question
Could someone please help me with this C++ project, the instructions are below:Consider a class Movie that contains information about a movie. The class has the following attributes:
The movie name The MPAA rating (for example, G, PG, PG-13, r) Rotten Tomatoes score (from 0 – 100) The number of viewers that have rated this movie as a 1 (Terrible) The number of viewers that have rated this movie as a 2 (Bad) The number of viewers that have rated this movie as a 3 (oK) The number of viewers that have rated this movie as a 4 (Good) The number of viewers that have rated this movie as a 5 (Great) The class has at least the following public methods (add other methods as you see fit):
Accessor and mutator methods for movie name, MPAA rating, and Rotten Tomatoes score. Write a function addRating() that takes an integer as an input parameter. The function should verify that the parameter is a number between 1 and 5, and if so, increment the number of people rating the movie that match the input parameter. For example, if 3 is the input parameter, then the number of people that rated the movie as a 3 should be incremented by 1. Write another function, getAverage(), that returns the average value for all of the movie ratings. Write a function called tomatometer which returns “Rotten” if the Rotten Tomatoes rating is under 60 and “Fresh” if the rating is 60 or above. Finally, add a constructor that allows the programmer to create the object with a specified name and MPAA rating. The number of people rating the movie should be set to 0 in the constructor. The Rotten Tomatoes rating should be set to zero. Test the class by writing a main function in a file called Project1.cpp that creates 3 movie objects, adds at least five ratings for each movie, and outputs the movie name, MPAA rating, Rotten Tomatoes rating, whether it is Fresh or Rotten, and average viewer rating for each movie object.
Other requirements
Follow the course code style guide and good programming practices. Put your class interface in a header file called Movie.h and document each method with in the same manner as the BagInterface (see pages 24-25 in the book). This is called java-doc style commenting. Put your class implementation in a source file called Movie.cpp. Make sure your code handles incorrect/unusual data properly. If you wrote the program in an environment other than Visual Studio 2017 it is your responsibility to ensure that it works in VS 2017 (which is what I’ll be grading in). Put a comment at the top of all files with your full name, class number, and assignment name like so: // Joe Smith // CS Programming Project 1 Could someone please help me with this C++ project, the instructions are below:
Consider a class Movie that contains information about a movie. The class has the following attributes:
The movie name The MPAA rating (for example, G, PG, PG-13, r) Rotten Tomatoes score (from 0 – 100) The number of viewers that have rated this movie as a 1 (Terrible) The number of viewers that have rated this movie as a 2 (Bad) The number of viewers that have rated this movie as a 3 (oK) The number of viewers that have rated this movie as a 4 (Good) The number of viewers that have rated this movie as a 5 (Great) The class has at least the following public methods (add other methods as you see fit):
Accessor and mutator methods for movie name, MPAA rating, and Rotten Tomatoes score. Write a function addRating() that takes an integer as an input parameter. The function should verify that the parameter is a number between 1 and 5, and if so, increment the number of people rating the movie that match the input parameter. For example, if 3 is the input parameter, then the number of people that rated the movie as a 3 should be incremented by 1. Write another function, getAverage(), that returns the average value for all of the movie ratings. Write a function called tomatometer which returns “Rotten” if the Rotten Tomatoes rating is under 60 and “Fresh” if the rating is 60 or above. Finally, add a constructor that allows the programmer to create the object with a specified name and MPAA rating. The number of people rating the movie should be set to 0 in the constructor. The Rotten Tomatoes rating should be set to zero. Test the class by writing a main function in a file called Project1.cpp that creates 3 movie objects, adds at least five ratings for each movie, and outputs the movie name, MPAA rating, Rotten Tomatoes rating, whether it is Fresh or Rotten, and average viewer rating for each movie object.
Other requirements
Follow the course code style guide and good programming practices. Put your class interface in a header file called Movie.h and document each method with in the same manner as the BagInterface (see pages 24-25 in the book). This is called java-doc style commenting. Put your class implementation in a source file called Movie.cpp. Make sure your code handles incorrect/unusual data properly. If you wrote the program in an environment other than Visual Studio 2017 it is your responsibility to ensure that it works in VS 2017 (which is what I’ll be grading in). Put a comment at the top of all files with your full name, class number, and assignment name like so: // Joe Smith // CS Programming Project 1 Could someone please help me with this C++ project, the instructions are below:
Consider a class Movie that contains information about a movie. The class has the following attributes:
The movie name The MPAA rating (for example, G, PG, PG-13, r) Rotten Tomatoes score (from 0 – 100) The number of viewers that have rated this movie as a 1 (Terrible) The number of viewers that have rated this movie as a 2 (Bad) The number of viewers that have rated this movie as a 3 (oK) The number of viewers that have rated this movie as a 4 (Good) The number of viewers that have rated this movie as a 5 (Great) The class has at least the following public methods (add other methods as you see fit):
Accessor and mutator methods for movie name, MPAA rating, and Rotten Tomatoes score. Write a function addRating() that takes an integer as an input parameter. The function should verify that the parameter is a number between 1 and 5, and if so, increment the number of people rating the movie that match the input parameter. For example, if 3 is the input parameter, then the number of people that rated the movie as a 3 should be incremented by 1. Write another function, getAverage(), that returns the average value for all of the movie ratings. Write a function called tomatometer which returns “Rotten” if the Rotten Tomatoes rating is under 60 and “Fresh” if the rating is 60 or above. Finally, add a constructor that allows the programmer to create the object with a specified name and MPAA rating. The number of people rating the movie should be set to 0 in the constructor. The Rotten Tomatoes rating should be set to zero. Test the class by writing a main function in a file called Project1.cpp that creates 3 movie objects, adds at least five ratings for each movie, and outputs the movie name, MPAA rating, Rotten Tomatoes rating, whether it is Fresh or Rotten, and average viewer rating for each movie object.
Other requirements
Follow the course code style guide and good programming practices. Put your class interface in a header file called Movie.h and document each method with in the same manner as the BagInterface (see pages 24-25 in the book). This is called java-doc style commenting. Put your class implementation in a source file called Movie.cpp. Make sure your code handles incorrect/unusual data properly. If you wrote the program in an environment other than Visual Studio 2017 it is your responsibility to ensure that it works in VS 2017 (which is what I’ll be grading in). Put a comment at the top of all files with your full name, class number, and assignment name like so: // Joe Smith // CS Programming Project 1
Explanation / Answer
/* ********************************************** CODE BEGINS ********************************************** */
#include <string.h> // Needed for the strcpy function
class Movie {
private:
// All the data members of the class
char *Name;
char *MPAARating;
unsigned RTScore;
unsigned num1Rating, num2Rating, num3Rating, num4Rating, num5Rating;
public:
// All the accessor and mutator methods for the data members
char *getName() {
char *retName;
strcpy(retName, this->Name);
return(retName);
}
void setName(char *Name) {
strcpy(this->Name, Name);
return;
}
char *getMPAARating() {
char *retMPAARating;
strcpy(retMPAARating, this->MPAARating);
return(retMPAARating);
}
void setMPAARating(char *MPAARating) {
strcpy(this->MPAARating, MPAARating);
return;
}
unsigned getRTScore() {
return(this->RTScore);
}
void setRTScore(unsigned RTScore) {
if(0 <= RTScore && RTScore <= 100)
this->RTScore = RTScore;
return;
}
// Add a rating to the database
void addRating(int Rating) {
switch(Rating) {
case 1: this->num1Rating++;
break;
case 2: this->num2Rating++;
break;
case 3: this->num3Rating++;
break;
case 4: this->num4Rating++;
break;
case 5: this->num5Rating++;
break;
}
return;
}
// Calculate and return the average rating of the movie
float getAverage() {
return((this->num1Rating+2*this->num2Rating+3*this->num3Rating+4*this->num4Rating+5*this->num5Rating)/(this->num1Rating+this->num2Rating+this->num3Rating+this->num4Rating+this->num5Rating));
}
// Return result based on Rotten Tomatoes score
char *tomatometer() {
char *retRTScore;
if(this->RTScore < 60) strcpy(retRTScore, "Rotten");
else if(this->RTScore >= 60) strcpy(retRTScore, "Fresh");
return(retRTScore);
}
// Parametrized constructor for the Movie objects
Movie(char *Name, char *MPAARating) {
strcpy(this->Name, Name);
strcpy(this->MPAARating, MPAARating);
this->RTScore = 0;
this->num1Rating = 0;
this->num2Rating = 0;
this->num3Rating = 0;
this->num4Rating = 0;
this->num5Rating = 0;
}
};
/* *********************************************** CODE ENDS *********************************************** */
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.