Objectives:
Problem: Redbox needs 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
Classes
Node
Binary Search Tree
User Interface and Input: There is no user interface for this program.
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 may not have a newline character) in inventory.dat will be formatted as follows (NOTE: < text> represents a variable value):
"< title>",< quantity available>,< quantity rented>
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 may not end with a newline character):
add "< title>",< number to add>
remove "< title>",< number to remove>
rent "< title>"
return "< title>"
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. To be valid, the line must follow the format exactly. Also, do not assume that a title in the transaction log will be in the tree.
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 formatted columns that line up the data nicely:
Write the report to a file named redbox_kiosk.txt.