Random Character Program Assignment!

You must follow these requirements exactly.
Your program must loop, asking for character names that may contain spaces, until the
word "quit" is entered. Each name should be added to a vector. Once “quit” is entered,
loop through the names vector and print out the stats.
There are three attributes of a DnD character for which you will write specific functions.
These are the signatures.
void PrintCharacterStats(string name);
string ChooseRace();
string ChooseAlignment();
string ChooseBehavior();
Each chooses one value from an array of predefined values at random.
string ChooseRace();
can return one of:
● Human
● Orc
● Elf
● Dwarf
● Gnome
string ChooseAlignment();
can return one of:
● Lawful
● Neutral
● Chaotic
string ChooseBehavior();
can return one of:
● Good
● Neutral
● Evil
You must write a function returning a random number within a give range. It will have
the signature:
int RangeRand(int min, int max);
It will return a random integer whose minimum value is specified as the first argument.
Its maximum value is one less than the second argument. For example RangeRand(0, 10)
returns a random integer from 0 to (including) 9. The mod operator % is important here.
You must write a function return a "stat". Stats can range between 6 and 18 inclusive.
The highest (18) is special. If you roll an 18 (choose 18 at random) the character gets a
special massive boost which comes in the form of a number between 0 and 100
inclusive. Because of this, your function returns a string - not a number.
string PickStat();
See the sample output for an example of non-18 values and one special 18 value. You
will choose stats for:
● Strength
● Dexterity
● Intelligence
● Charisma
● Wisdom
Health is different - it ranges from 6 to 30 inclusive.
As a hint, here are the include files I used when writing my implementation:
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
Style: Sometimes you can have dozens of includes. If they are in an order, they are
easier to glance through.
void PrintCharacterStats(string name);
Should Print out one characters stats following the format in the sample output.
Sample output
Enter character's name - use "quit" to exit: Hector the Horrible
Enter character's name - use "quit" to exit: Furry Curry Murray
Enter character's name - use "quit" to exit: quit
Hector the Horrible (Elf) is Neutral alignment and Neutral behavior
Health: 15
Strength: 8
Dexterity: 13
Intelligence: 7
Charisma: 16
Wisdom: 6
Enter character's name - use "quit" to exit:
Furry Curry Murray (Orc) is Lawful alignment and Evil behavior
Health: 17
Strength: 17
Dexterity: 9
Intelligence: 9
Charisma: 8
Wisdom: 18 / 74

This is the context of the assignment.. this is my code so far

#include <iostream>
#include <ctime>



int SelectRandomm(int min, int max);
void PrintNum(int num);


int main()
{
vector <string> alignments = "Lawful", "Neutral", "Chaotic", 3

double min;
double max;

int random;
srand(time(0));
random = SelectRandom (min, max);

return 0;
}

int SelectRandom(int min, int max)
{
int retVal;
retVal = (rand() % (max - min)) + min;

return retVal;
}

I'm not sure if this is the right place to start or if this is correct! If someone could lead me in the right direction that would be great!!
#include <iostream>
#include <string>
#include <vector>

#include <ctime>
using namespace std;

int SelectRandom(int min, int max);
void PrintNum(int num);

void PrintCharacterStats(string name);
string ChooseRace();
string ChooseAlignment();
string ChooseBehavior();

int main()
{
std::vector <std::string> race{ "Human", "Orc", "Elf", "Dwarf", "Gnome", 5 };
std::vector <std::string> alignments{ "Lawful", "Neutral", "Chaotic", 3 };
std::vector <std::string> behavior{ "Good", "Neutral", "Evil", 3 };
constexpr int MIN{ 0 };
constexpr int MAX{ 100 };

int random{};

srand(static_cast<size_t>(time(nullptr)));

random = SelectRandom(MIN, MAX);

return 0;
}

int SelectRandom(int min, int max)
{
int retVal;
retVal = (rand() % (max - min)) + min;

return retVal;



}

string ChooseRace()
{
retVal = races[SelectRandom(, );

return retVal;
}

string ChooseAlignment()
{
retVal = Alignment[SelectRandom(, ); ]

return retVal;
}

string ChooseBehavior();
{
retVal = Behavior[SelectRandom(, ); ]
}
Your program must loop, asking for character names that may contain spaces, until the
word "quit" is entered.
I don't see a loop in your code.
Topic archived. No new replies allowed.