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

Write the definitions of the function of the class videoBinaryTree not given in

ID: 3628084 • Letter: W

Question

Write the definitions of the function of the class videoBinaryTree not given in the Programming Example Video Store. Also write a program to test the video store program.

Program for Chapter 11 and 13 is here:

http://books.google.com/books?id=NXH_fbFDfSgC&pg=PA1023&lpg=PA1023&dq=Data+Structures+using+C%2B%2B+%22Programming+Example+Video+Store%22&source=bl&ots=TiXhcLaN8t&sig=BpMZeUQO-saBypyVmzE9nwhlGKA&hl=en&ei=HXofTbHCI8T38AbLkYD_DQ&sa=X&oi=book_result&ct=result&resnum=6&ved=0CDMQ6AEwBQ#v=onepage&q&f=false

Explanation / Answer

public class VideoBinaryTree extends BinarySearchTree { //default constructor //Postcondition: root = null; public VideoBinaryTree() { super(); } //copy constructor public VideoBinaryTree(VideoBinaryTree otherList) { super(otherList); } //Method to search the video list for a //particular video, specified by the parameter title. //Postcondition: If the video is found, a reference to // the node containing the video is returned; // otherwise, the value null is returned. private BinaryTreeNode searchVideoList(String title) { boolean found = false; //set found to false BinaryTreeNode current = null; VideoElement temp = new VideoElement(); temp.setVideoInfo(title, "", "", "", "", "", 0); if(root == null) //the tree is empty System.out.println("Cannot search an empty list. "); else { current = root; //set current point to the root node //of the binary tree found = false; //set found to false while(current != null && !found) //search the tree if(current.info.equals(temp)) //theitem is found found = true; else if(current.info.compareTo(temp) > 0) current = current.llink; else current = current.rlink; } //end else return current; }//end searchVideoList //Method to search the list to see if a particular //title, specified by the parameter title, is in the store. //Postcondition: Returns true if the title is found; // false otherwise. public boolean videoSearch(String title) { System.out.println("See Programming Exercise 8."); return false; } //Method to determine if the video specified by the //parameter title is available. //Postcondition: Returns true if at least one copy of the // video is available, false otherwise. public boolean isVideoAvailable(String title) { System.out.println("See Programming Exercise 8."); return false; } //Method to check in a video returned by a customer. //The parameter title specifies the video to be checked in. //Postcondition: If the video returned is from the // store, its copiesInstock is incremented // by one; otherwise, an appropriate message // is printed. public void videoCheckIn(String title) { System.out.println("See Programming Exercise 8."); } //Method to check out a video, that is, rent a video. //The parameter title specifies the video to be checked out. //Postcondition: If a video is available, its copiesInStock // is decremented by one; otherwise, an // appropriate message is printed. public void videoCheckOut(String title) { BinaryTreeNode location; VideoElement temp; location = searchVideoList(title); //search the list if(location != null) { temp = (VideoElement) location.info; temp.checkOut(); } else System.out.println("The store does not carry " + "this video"); } //Method to determine if the video specified by the //parameter title is in store. //Postcondition: Returns true if the video is // in the store; false otherwise. public boolean videoCheckTitle(String title) { System.out.println("See Programming Exercise 8."); return false; } //Method to update the number of copies of a video //by adding the value of the parameter num. The //parameter title specifies the name of the video //for which the number of copies is to be updated. //Postcondition: If video is found; then // copiesInStock = copiesInStock + num; // otherwise, an appropriate message is // printed. public void videoUpdateInStock(String title, int num) { System.out.println("See Programming Exercise 8."); } //Method to reset the number of copies of a video. //The parameter title specifies the name of the video //for which the number of copies is to be reset and the //parameter num specifies the number of copies. //Postcondition: If video is found, then // copiesInStock = num; // otherwise, an appropriate message // is printed. public void videoSetCopiesInStock(String title, int num) { System.out.println("See Programming Exercise 8."); } //Method to print the titles of all the videos in stock. public void videoPrintTitle() { inorderTitle(root); } //Method to print the titles of all the videos in //the tree pointed to by p. private void inorderTitle(BinaryTreeNode p) { VideoElement temp; if(p != null) { inorderTitle(p.llink); temp = (VideoElement) p.info; temp.printTitle(); inorderTitle(p.rlink); } } }