I hate asking this explicitly because i'm trying to learn, and want to have that eureka moment when it clicks and I understand whats going on, but that doesn't seem to be happening. And I have been trying to find a mentor or mentors that can put up with what might seem like blatantly stupid questions. So far this community has been extremely fantastic at that.
So going over this problem, I have restarted and have decided to go with a similar method that you have suggested with two different Actions, instead of one big loop.
The first being, asking the user a simple input of the desired input a std::string in the form of <Dog|Cat Name>. Creating a list of "Pets".
1 2 3 4 5 6
|
// Where Pet is a base-class I have constructed for my derived-classes Dog and Cat
std::vector< Pet* > listOfPets;
std::string userCommand;
std::cout << "Enter the list of pet type and pet name in the form <Dog|Cat Name>. When you are finished enter <done> \n";
|
Wanting that list of pets stored in a std::vector<Pets*>
Having conditional loops while the user is inputting the list
something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// 1.) while the userCommand is not equal to done, continue to add to the list
while ( userCommand != "done" )
{
std::cin >> userCommand;
// 2.) essentially have to check for 3 possibilities "done", "Dog|Cat Name",
//or "neither of the previous two options"
// first things first in the while loop stop if it is "done"
if ( userCommand != "done" )
{
//here is where I run into not understanding the function calls on std::string to check
//for specific words (thinking of using .find() ? ) and how the proper syntax
//of the arguments should be. Parsing the information accordingly from std::cin?
//3.) Ultimately if userCommand is a Cat or Dog with a Name, then storing
//the string in a vector to be later called upon when addressing them
}
}
|
And the second Action after collecting the data from the user,
Utilizing the stored data to talk to specific pets on the list, having them respond in their "language" Woof or Meow
* not so much focusing on the second aspect of it right now though, that will come later
Any help or links to useful literature would is greatly appreciated.
One day I hope i can give back to this community too.