Question: This prgoram is in C, help me with the question shown in picture, code provided below #include #include #include #include #define MAX_STR_LEN 1024 // Used
This prgoram is in C, help me with the question shown in picture, code provided below
#include
#include
#include
#include
#define MAX_STR_LEN 1024
// Used to store information about the cast of a movie (Implement AFTER everything else)
typedef struct castList_struct
{
} CastList;
// Used to store information about a movie
typedef struct movieReview_struct
{
// IMPLEMENT THIS FIRST - else the code won't compile
} MovieReview;
// Used to store a linked list of MovieReview nodes
typedef struct reviewNode_struct
{
// IMPLEMENT THIS FIRST - else your code won't compile
} ReviewNode;
/**
* Allocates a new, empty ReviewNode, and initializes its contents with the given values.
*
* INPUT:
* - title: the title of the movie
* - studio: the studio where the movie was produced
* - year: the year in which the movie was produced
* - BO_total: the amount of money this movie grossed at the box office
* - score: the average review score given to this movie
*
* NOTE: - The *next pointer for the new node MUST be set to NULL
*
* RETURN:
* - if something goes wrong, return NULL,
* - else:
* - the newly allocated node, initialized with:
* - node.next
* - node.review:
* - movie_title
* - movie_studio
* - year
* - BO_total
* - score
4.- What to do for Part 1 Your task for part 1 can be summarized as implementing the compound data structures that will allow you to build a linked list of movie reviews. a) (5 marks) Implement the compound data type that stores one movie review. This compound type will be called 'Movie Review' and will contain the following fields: movie_title movie_studio year BO_total score cast - A string with length 1024 - A string with length 1024 - An int in 1920-2999 - (the Box Office total) A double floating point value - For part 1 this is just an int in 0-100 (like Rotten Tomatoes scores!) - A pointer to a linked list of cast members who were in the movie (there is an associated data type for this called 'CastList', you'll implement that at the end!). Make sure you have the correct types, and the correct lengths for strings, as well as the correct names for the fields - otherwise your code won't pass the tests. b) [5 marks] Implement the compound data type required to hold a linked list node with one movie review. The type must be called 'ReviewNode' and must contain: review *next - A'Movie Review' variable containing information for one movie - The pointer to the next node in the list c) (5 marks) Implement the newMovie ReviewNode(title, studio, year, BO_total, score) function. This 'function allocates and initializes a new movie review. Your function must return the pointer to the newly allocated, initialized node. d) (10 marks) Implement the function insert Movie Review(title,studio,year,BO_total,score, head). This function: - Takes as input the information for a movie review. - Takes as input the current head of the linked list of reviews. - Checks that the requested movie is not already in the linked list (if it is in the list, it prints "Sorry, that movie already exists" and returns the current list head pointer. - Obtains a new linked-list node, and fills in the movie information. - Inserts the new node at the head of the linked list. - Returns a pointer to the new head node * - cast
*/
ReviewNode *newMovieReviewNode(char *title, char *studio, int year, double BO_total, int score)
{
/***************************************************************************/
/********** TODO: Complete this function *********************************/
/***************************************************************************/
return NULL; // Remove this before you implement your solution!
}
/**
* Inserts a new movie review into the linked list, if it does not exist already.
*
* INPUT:
* - title: the title of the movie
* - studio: the studio where the movie was produced
* - year: the year in which the movie was produced
* - BO_total: the amount of money this movie grossed at the box office
* - score: the average review score given to this movie
*
* OUTPUT: - head: the (potentially new) head of the linked list of reviews
*
* RETURN: - the (potentially new) head node of the linked list
*
* NOTE:
* - If head == NULL, then the list is still empty
* - Inserts the new movie review *at the head* of the linked list
* - MUST check that the movie is not already in the list before inserting (there should be no
* duplicate entries). If a movie with matching title, studio, and year is already in the list,
* nothing is inserted and the function returns the current list head.
*/
ReviewNode *insertMovieReview(char *title, char *studio, int year, double BO_total, int score,
ReviewNode *head)
{
/***************************************************************************/
/********** TODO: Complete this function **********************************/
/***************************************************************************/
return NULL; // Remove this before you implement your solution!
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
