subject

Created a fully templatized map: It should have two template variables, one for the key and one for the data. I am referring to them as KEY and DATA both here and in the starting code. This can just be two parallel arrays, one for the keys and one for the data. Create a constant k_max to indicate the maximum # of data entries in your map. k_max should be between 5 and 2000. Small is perfectly fine. The following methods must exist for this map:
A default constructor. This constructor zeros any indexes and then stops.
A find function that returns the index where the KEY is found. You will need create the find function first before you do the insert function below. You should use the == operator to determine if it's found.
An insert function that takes a KEY and a DATA.; This function will not insert if the map is full or the key already exists. It will print an error message. This function will print what it is trying to insert.
A constructor that takes a single KEY and a single DATA. It should initialize the index to zero and then call the insert function for that key and data.
A function that loops through the map and prints it.
All the code needs to be in the .h. Only do one-line methods in the interface and larger functions in the .h but separate from the interface. (Note: functions with loops should never be inline, even if you could squish them into one line.
// CST136_4_93.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include
#include
using std::string;
// I have a standardized to-do where I ask you to create a variable using your
// template class. It is:
// todo: VAR {variable name} : KEY -> datatype, DATA -> datatype
// ie VAR: {solar} - KEY -> string, DATA -> int
// which means: create a map variable "solar" that takes the key that is a string
// and data that is an int
void test_insert();
void test_my_class();
int main()
{
std::cout << "Start Student Tests" << std::endl;
// you can add your own tests between this start and stop.
std::cout << "END Student Tests" << std::endl;
std::cout << "START testing" << std::endl;
test_insert();
test_my_class();
std::cout << "END testing" << std::endl;
}
void test_insert()
{
std::cout << std::endl;
uncomment this when you are ready and follow the instruction
todo: var: {solar} - key -> string, data -> int
create a map variable "solar" that takes the key that is a string and data that is an int
// solar; // update this line to make your variable "solar" as described above.
std::cout << "start test_insert" << std::endl;
don't change these lines other then to uncomment them.
std::cout << " test: single, not duplicate, inserts without issue." << std::endl;
// solar. insert("moon", 238900);
// solar. insert("mars", 33900000);
// solar. insert("leo satellite", 1200);
std::cout << " END: Single, not duplicate, inserts" << std::endl;
std::cout << " TEST: print";
std::cout << " Should print all three entries." << std::endl;
// solar. print();
std::cout << " END: print" << std::endl;
std::cout << " TEST: Duplicate insert of Moon" << std::endl;
std::cout << " Note: Produces an error message within the insert" << std::endl;
// solar. insert("moon", 238900);
std::cout << " END: Duplicate insert of Moon" << std::endl;
std::cout << "END test_insert" << std::endl;
}
void test_my_class()
{
std::cout << std::endl;
std::cout << "START test_insert_my_class()" << std::endl;
todo: VAR {intkey} - : KEY -> int , DATA -> your class
std::cout << " TEST: Insert of your Class as DATA" << std::endl;
Uncomment the loop below. (Don't change it after)
//for (int i = 0; i < k_max; i++)
// intkey. insert(i, test[i]);
//intkey. print();
leave this loop alone
std::cout << " END: Insert of your Class as DATA" << std::endl;
todo: VAR {classkey} - : KEY -> your class , DATA -> int
Uncomment the loop below. (Don't change it after)
std::cout << " TEST: Insert of your Class as KEY" << std::endl;
//for (int i = 0; i < k_max; i++)
// classkey. insert(test[i], i);
// // note: this also tests your overloaded << operator.
//classkey. print();
std::cout << " END: Insert of your Class as KEY" << std::endl;
leave this loop alone
std::cout << " TEST: Duplicate / Full Insert" << std::endl;
Note: this also tests your overloaded == operator. :)
you will get either a full error or a duplicate error. Doesn't matter which.
//classkey. insert(test[0], 0);
std::cout << " END: Duplicate Insert" << std::endl;
std::cout << "END test_insert_my_class()" << std::endl;
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:30
Avariable definition defines the name of a variable that will be used in a program, as well as
Answers: 3
question
Computers and Technology, 22.06.2019 21:30
After you clean an engine with hot water spray, it seems to stall; when it doesn't stall, it's idling noisily. technician a says to check for loose bolts on the flex plate near the torque converter. technician b says to wipe down the spark plug wires and the distributor cap. who is correct? a. technician a b. both technicians a and b c. technician b
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Write the html code to make a link out of the text ā€œall about puppiesā€. it should link to a pdf called ā€œpuppies.pdfā€ inside the ā€œdocumentsā€ folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
You know the right answer?
Created a fully templatized map: It should have two template variables, one for the key and one for...
Questions
question
Mathematics, 06.12.2021 07:40
question
Spanish, 06.12.2021 07:40
question
SAT, 06.12.2021 07:50
question
Arts, 06.12.2021 07:50