Question: Could really use some help with this assignment Using only C++ Please read carefully before starting. All files that are being used are provided below.
Could really use some help with this assignment
Using only C++
Please read carefully before starting.
All files that are being used are provided below.
Table1 header and template file are only examples, they are not being used for this problem. The table2.h file and testtab2.cpp are the files being used.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FILE: table2.h // TEMPLATE CLASS PROVIDED: Table
#ifndef TABLE2_H #define TABLE2_H #include // Provides the STL list class
namespace main_savitch_12B { template
#include "table2.template" // Include the implementation
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FILE: testtab2.cxx // An interactive test program for the second table ADT.
#include
// Struct definition for the test_record_type, which has a key and a double. struct test_record_type { int key; double data; };
// PROTOTYPES for functions used by this test program: void print_menu( ); // Postcondition: A menu of choices for this program has been written to cout.
char get_user_command( ); // Postcondition: The user has been prompted to enter a one character command. // The next character has been read (skipping blanks and newline characters), // and this character has been returned.
test_record_type get_record( ); // Postcondition: The user has been prompted to enter data for a record. The // key has been read, echoed to the screen, and returned by the function.
int get_key( ); // Postcondition: The user has been prompted to enter a key for a record. The // items have been read, echoed to the screen, and returned by the function.
int main( ) { table do { print_menu( ); choice = toupper(get_user_command( )); switch (choice) { case 'S': cout return EXIT_SUCCESS; } void print_menu( ) // Library facilities used: iostream.h { cout char get_user_command( ) // Library facilities used: iostream.h { char command; cout > command; // Input of characters skips blanks and newline character return command; } test_record_type get_record( ) // Library facilities used: iostream.h { test_record_type result; cout > result.data; cout int get_key( ) // Library facilities used: iostream.h { int key; do { cout > key; } while (key ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // FILE: table1.h (part of the namespace main_savitch_12A) // TEMPLATE CLASS PROVIDED: table #ifndef TABLE1_H #define TABLE1_H #include namespace main_savitch_12A { template ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // FILE: table1.template // TEMPLATE CLASS IMPLEMENTED: table (see table1.h for documentation) // INVARIANT for the table ADT: // 1. The number of records in the table is in the member variable used. // 2. The actual records of the table are stored in the array data, with // a maximum of CAPACITY entries. Each used spot in the array has a // non-negative key. Any unused record in the array has a key field of // NEVER_USED (if it has never been used) or PREVIOUSLY_USED (if it once // was used, but is now vacant). #include namespace main_savitch_12A { template template template template used = 0; for (i = 0; i template assert(entry.key >= 0); // Set index so that data[index] is the spot to place the new entry. find_index(entry.key, already_present, index); // If the key wasn't already there, then find the location for the new entry. if (!already_present) { assert(size( ) data[index] = entry; } template assert(key >= 0); find_index(key, found, index); if (found) { // The key was found, so remove this record and reduce used by 1. data[index].key = PREVIOUSLY_USED; // Indicates a spot that's no longer in use. --used; } } template assert(key >= 0); find_index(key, found, index); return found; } template assert(key >= 0); find_index(key, found, index); if (found) result = data[index]; } template template template count = 0; i = hash(key); while((count template
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
