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 05:00
Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive. after the loop terminates, it prints out, on a line by itself and separated by spaces, the sum of all the even integers read, the sum of all the odd integers read, a count of the number of even integers read, and a count of the number of odd integers read, all separated by at least one space. declare any variables that are needed. assume the availability of a variable, stdin, that references a scanner object associated with standard input. that is, stdin = new scanner(system.in); is given.
Answers: 3
question
Computers and Technology, 22.06.2019 07:20
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
question
Computers and Technology, 22.06.2019 19:10
What a backup plan that you have created in a event you encounter a situation
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Cloud computing service providers manage different computing resources based on the services they offer. which resources do iaas and paas providers not manage? iaas providers do not manage the for the client, whereas paas providers usually do not manage the for their clients. iaas- storage server operating system network paas- applications interafce storage vertualiation
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, 21.09.2019 01:00
question
Biology, 21.09.2019 01:00
question
Computers and Technology, 21.09.2019 01:00
question
Social Studies, 21.09.2019 01:00
question
Biology, 21.09.2019 01:00
Questions on the website: 13722367