Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LANGUAGE IS C BELOW IS THE STARTER CODE. EDIT THE SAME FILE RESPECTIVE OF WHAT IS ASKED. #include #include #include #include #define MAX_STR_LEN 1024 /*

image text in transcribed

LANGUAGE IS C

BELOW IS THE STARTER CODE. EDIT THE SAME FILE RESPECTIVE OF WHAT IS ASKED.

#include #include #include #include

#define MAX_STR_LEN 1024

/* Compound data type declarations */ /***************************************************************************/ /****** TODO *********/ /****** In the space below, complete the definitions of the compound *******/ /****** data types that will be needed to implement the movie review *******/ /****** linked list. This includes the MovieReview type, and the *******/ /****** ReviewNode. Details about the contents of these can be *******/ /****** found in the assignment handout. Read them carefully! *******/ /****** *******/ /***************************************************************************/

// 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

return NULL; // Remove this before you implement your solution! }

/** * Finds and returns a ReviewNode containing information that matches the input query: * - title * - studio * - year * but if no such ReviewNode exists, returns NULL. * * INPUT: * - title: the title of the movie * - studio: the studio where the movie was produced * - year: the year in which the movie was produced * * RETURN: * - if a review matching the query is found: * the node that contains that review. * - else: * NULL */ ReviewNode *findMovieReview(char *title, char *studio, int year, ReviewNode *head) { /***************************************************************************/ /********** 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! }

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) 15 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 15 marks) Implement the new Movie ReviewNodeftitle, stadio, 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) 110 marks Implement the function insert Movie Review (titleshdi, year, 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 (uf it is in the list 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. 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) 15 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 15 marks) Implement the new Movie ReviewNodeftitle, stadio, 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) 110 marks Implement the function insert Movie Review (titleshdi, year, 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 (uf it is in the list 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

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions

Question

PESTEL ANALYSIS - OVERALL ELECTRIC CAR INDUSTRY ANALYSIS P E S T

Answered: 1 week ago

Question

Identify HRM systems, practices, and policies.

Answered: 1 week ago