Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implementing this function for me. void addMovieNode(int ranking, std::string title, int releaseYear, int quantity); 4. addMovieNode method: You should create a MovieNode with the given

implementing this function for me. void addMovieNode(int ranking, std::string title, int releaseYear, int quantity);

4. addMovieNode method: You should create a MovieNode with the given information, then insert it into the binary search tree in the correct position: the tree should be sorted alphabetically by title. You may use the string::compare() method from the C++ standard library for alphabetical comparison. See http://www.cplusplus.com/reference/string/string/compare/ for usage.

There is no menu option to add a movie; adding is done by reading the inventory list and inserting movie per row of the input text file. (This method is only used while building the tree)

hpp file :

#ifndef MOVIETREE_HPP #define MOVIETREE_HPP

#include

/* MovieNode: Node object to store in * the binary search tree (BST). Each movie's * info will be stored in one node. */ class MovieNode { public: // instance variables int ranking; std::string title; int year; int quantity; MovieNode *leftChild; MovieNode *rightChild;

// constructors MovieNode() { ranking = -1; year = 0; quantity = -1; leftChild = rightChild = nullptr; }; MovieNode(int in_ranking, std::string in_title, int in_year, int in_quantity) { ranking = in_ranking; title = in_title; year = in_year; quantity = in_quantity; leftChild = rightChild = nullptr; }

};

/* MovieTree: Class implementing the BST: * - You will implement the methods marked TODO. * - Root of tree is pointed at by 'root' */ class MovieTree { private: // instance var pointing to root node in tree MovieNode* root;

public: // Constructor (TODO) MovieTree();

// Destructor (TODO) ~MovieTree();

// Descr: see 'print the entire inventory' // in the homework manual. (TODO) void printMovieInventory();

// Descr: add movie to BST, at spot in tree // alphabetically-sorted by title. (TODO) // param rating: IMDB rating of movie // param title: title of movie // param releaseYear: release year of movie // param quantity: # of copies available to rent void addMovieNode(int ranking, std::string title, int releaseYear, int quantity);

// Descr: Search the BST for the given title and // print that movie's info in the predefined // format. See 'Find a movie' in the manual. (TODO) // param title: title of node to find void findMovie(std::string title);

// Descr: update the inventory to indicate a movie // has been rented and print predefined info. // See 'Rent a movie' in the manual. (TODO) // param title: title of node to rent void rentMovie(std::string title); };

#endif // MOVIETREE_HPP

parent node is not defined in hpp, dont give me the answer with it.

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

Question

How can speakers manage speaking anxiety?

Answered: 1 week ago