Question:
Objective: Use structures and pointers to create linked lists. Use knowledge of pointers to modify linked lists. Implement a recursive function.
Problem: FreePlay Arcade in Richardson has a primitive flat file database that needs to be updated. This database contains the names, high scores (w/ initials) and the total number of plays of their games. The database also contains the total amount each game would earn if not on free play. You will build a simple interface to interact with the database.
Details: The interface will provide the following options:
1. Add a record to the database
2. Search for a record and display it
3. Edit a record
4. Delete a record
5. Sort records
Add a record: Create a new node and add it to the database
Search for a record: The search term will be a word or phrase. Search through the entries and display the complete record for any game that matches the search term.
Edit a record: With a given game name, the program should update the record and confirm the change by displaying the new record on the screen. The following items can be edited:
1. High score
2. Initials
3. Number of plays
If number of plays is edited, the revenue should be recalculated
$0.25 per play
Delete a record: User will enter a game name. The program should delete the record from the file. The best way to do this is to delete the record from the linked list.
Sort records: The records can be sorted in ascending order (A -> Z or increasing numerically) by either name or number of plays.
Input will come from a batch file. Output will be written to a file.
The linked list will be written to the database file at the end of the program
No need to remove and rename when a delete is performed
All records are stored in memory with a linked list of structures
All manipulation to the database should happen within the linked list, not the output file
When deleting - if a record does not exist, write an error message to the log file
Expect that some test cases will involve there being no inventory.dat file at execution
Validate all input into the program
No need to validate name as it can be practically anything
Write error messages to the log file if invalid input is encountered and ignore the command
Be prepared for anything in terms of user input
Error messages written to the output file should be in ALL CAPS.
Database Format: The database file will be named freeplay.dat. Each record in the database will be on a single line with the following format. Each field will be separated by a comma and a space
, , , , <\n>
- may be multiple words
- 9 digits
- 3 characters- no white space
- 4 digits- will have leading zeroes if value less than 1000
- <4 digits><2 digits> - will have leading zeroes if first four digits less than 1000
Input: All input will be file based. You will create a batch file to use with the database. The format for each option is listed below:
Add a record
1 "name" high_score initials plays $revenue<\n>
Search for a record
2
2 Search term may contain spaces
Edit a record
3
1 = high score
2 = initials
3 = number of plays
New value may not contain leading zeroes
Delete a record
4
Name may contain spaces
Sort records
5
A single word should follow the value: name or plays
Output: Each command in the input file will generate output to a file named freeplay.log. The output for each command is as follows:
Add a record
RECORD ADDED
Name:
High Score:
Initials:
Plays:
Revenue: mce_markerlt;value> - formatted to 2 decimal places
Search for a record
FOUND or NOT FOUND
If found
High Score:
Initials:
Plays:
Revenue: mce_markerlt;value> - formatted to 2 decimal places
Edit a record
UPDATED
UPDATE TO - VALUE
Name:
High Score:
Initials:
Plays:
Revenue: mce_markerlt;value> - formatted to 2 decimal places
Delete a record
RECORD DELETED
Name:
High Score:
Initials:
Plays:
Revenue: mce_markerlt;value> - formatted to 2 decimal places
Sort records
RECORDS SORTED BY