Question: Part C - 2 : RemoveHero Add a method called RemoveHero to the HeroesDB class. Declare your method in the HeroesDB.h file and define the
Part C: RemoveHero
Add a method called RemoveHero to the HeroesDB class. Declare your method in the HeroesDB.h file and define the method in the HeroesDB.cpp file CClass Methods
wschools.comThe method should take a string parameter that is the name of the hero to remove.
In the method, if groupedHeroes is empty, call the GroupHeroes method.
Check if the groupedHeroes map contains a key with the first letter of the name.
If the key is not found, print a message saying the hero was not found.
If the key is found, then get the vector for the key. The vector is the value stored in the map for the key.
call the BinarySearch method to get the index of the hero to remove for the vector.
If BinarySearch returns the index
then remove the hero from the vector
search for the hero in the heroes vector and remove the hero from the heroes vector.
Print that the hero was removed.
NOTE: if removing the hero makes the vector empty for the letter, then remove the letter which is the keyfrom the map.
If BinarySearch returns meaning the hero is not in the vectorprint a message that the hero was not found.
In main which is in HeroesVcppadd code to case of the switch. Using Input::GetString, ask the user to enter the name to find. Call RemoveHero passing the string that the user enters.
make sure that if the method is called again that the same hero searched for in the first call is no longer in the map.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
