Question
Redbox is in need of a program to track inventory and to generate a report for their DVD rental kiosks. Given a log of transactions
Redbox is in need of a program to track inventory and to generate a report for their DVD rental kiosks. Given a log of transactions including renting and returning DVDs as well as adding and removing DVD titles, the program will need to process each transaction and create a report after all transactions have been processed. The generated report will list all DVD titles stored in the kiosk as well as how many of each disc are in the kiosk.
Details: * The inventory will be held in a binary search tree * Use the DVD title to determine node placement in the tree * The binary tree will be seeded with an inventory file * Once seeded, the program will parse a transaction log to update the inventory * There are five possible transactions o Add new title o Add copies of title o Remove copies of a title o Rent a DVD o Return a DVD * Add new title o Create a new node and insert it into the tree * Add copies of title o Find the title in the tree and increase the number of available copies by the amount listed * Remove copies of a title o Find the title in the tree and reduce the number of available copies by the amount listed o If number available is zero and no copies are rented out, delete the node from the tree o There will not be more copies removed than available. * Rent a DVD o Reduce amount by one and increase rented amount by one * Return a DVD o Increase amount by one and reduce rented amount by one
Classes: Node - * Members o Title (string) o Available (int) o Copies Rented (int) o Left (node pointer) o Right (node pointer) * Methods o Overloaded constructor o Mutator o Accessor Binary Search Tree - * Members o Root (Node pointer) * Methods o Mutator o Accessor o Other methods that are necessary to interact with a binary search tree - Remember methods should be generic enough to be used on a binary tree regardless of the problem. - Any method that traverses the tree must be recursive. Input will be given in two files, inventory.dat and transaction.log. The program will read inventory.dat first. This will create the binary tree. Each line (except the last line which will not have a newline character) in inventory.dat will be formatted as follows:
After processing the inventory file, begin processing transaction.log. Each line of the file should follow one of the following formats (Note: the last line will not end with a newline character): add
The transaction file may contain errors due to network disruptions from the main server. For each line in the transaction log, validate that it follows one of the formats listed above. If it is the correct format, process the transaction. If the line is invalid, write the line to an error file (as described below). All numbers are expected to be integers. In order to be valid, the line must follow the format exactly. Output: A file named error.log will be created if any lines of transaction.log are invalid. Error.log will contain all invalid entries of the transaction file.
At the end of the program, create a formatted report to display each title, the number of copies available to rent for that title as well as the number of copies that are currently rented. The titles should be listed in alphabetical order (without the double quotes). The report should be arranged in three columns: Title Copies available Copies rented Write the report to a file named redbox_kiosk.txt.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started