CS 201

 

Create 2 VC++ Projects with the Files Given below

This part is just for practice:

Each of the "Test" files is a main to a simple project. RationalTest project creates a binary file of Rational objects - that's it. The rationaltest2 projects reads that binary file, and echos the Rational numbers to the standard output. It then resets the file to the beginning and reads the rational objects again. If ever an object has a top bigger than its bottom, the program backs 1 rational record inthe file, and writes the rational number with its top and bottom reversed. the program ends by resetting once again to the begining, and reading and echoing the file, with the changes that were made. The program demonstrates simple read/write random access file.

This file creates the binary file of Rational objects
RationalTest.cpp - View the Source

This file reads and echos the binary file of objects, then resets the file to the begining and rereads. If it reads a Rational in which the numerator is greater than the denominator, it writes a Rational object to the same slot, with the numerator and denominator switched.
RationalTest2.cpp - View the Source

This is the header to the Rational class
Rational.h - View the Source

This is the implementation to the Rational class
Rational.cpp - View the Source

Your Project

You are to write a simple menu-driven program to allow a user to request a record by KEY. You should search (read) the file for the record, and display it if it exists in your file. A user can delete a record. If it exists, you need to add its vacated block location to the free list. A user can add a new record. if it does not exist, you will take a free block from the free list, and place the record there. Be sure to update all "next record" and "previous record" pointers on all add and delete operations. A user can update a record. if the record existsall you need to do is to allow the user to enter a new field value, then write the record back to the file. Finally, you should allow the user to display the file to screen as well as write it to a text file (not a binary file).

Your record can be a couple of fixed-length strings and an ID field, say an integer. To maintain both record blocks and empty blocks, each physcal record will have a pointer (really a file offset) to the next physical block and the previous one. In a sense this will be similar to a linked list - but it will exist in a file, not in memory.

Make your data set large, at least 100 records (can be up to 10,000). Gather data randomly or get a large data file from the internet. The exact data is up to you, but you should have int class an integer key value, plus at least two other fields. At least one of them should be a string (use a C-style string which is fixed length, to allow for easy random access binary file movement with seekg() or seekp().