It looks like you might want to add a while loop that surrounds the menu input. As the program stands now, it will show the menu once, process the request and then exit.
Some other observations:
The use of an inner loop (or at least it will be once you put a while loop around the entire menu) if the choice is invalid is not a good design, as you are duplicating the code to input a menu choice. You'll also have to remember to change this loop if you change the data type of
choice
A header file should be very careful about using
#include
directives. In this case you only need to #include <string> for the definitions of your
string
members. And a header file should almost never include
using namespace std;
as this can cause unexpected results for clients that use the header. If you want to add that to the
implementation file, then that's a matter of style and/or coding standards. In general, though, you will find you'll get used to adding
std::
to standard library functions, objects, containers, etc fairly quickly.
You seem to be missing a
break
statement at then end of
case 1
in your implementation file.
You're essentially duplicating your data input, once for a file read, and again for a user prompt. If you want to change the Creature class, you'll have to remember to make the changes in both places. Assuming that you're reading the object data in the same order, regardless of the source, then maybe a function that could read a single creature's data, and knows whether to show a prompt or not might be a better way to go. Such a function might have a signature that looks like
bool getCreature(Creature& creature, std::istream& input, bool showprompt)