Code:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{
//Set variables for Character Stat Sheet
string charaFirstName, charaLastName, charaClass, enemyClass;
int charaStr, charaDex, charaInt, charaAgi, charaVit, charaChoice;
//Introduction and offering user to name their character
cout << "Welcome to The Simple Character Battle Simulator!!\n" << endl;
cout << "Please enter the first name of your character: ";
cin >> charaFirstName;
cout << "Please enter the last name of your character: ";
cin >> charaLastName;
//Providing list for classes, and allowing user to choose a class
cout << "\nHere is a list of classes for your character to choose from:\n" << endl;
cout << "1. Swordmaster" << endl;
cout << "2. Warlock" << endl;
cout << "3. Exorcist" << endl;
cout << "4. Rouge" << endl;
cout << "5. Sniper\n" << endl;
cout << "Please choose a class, and then enter the number of your chosen class: ";
cin >> charaChoice;
//Setting character stats based on class, and class name
if (charaChoice == 1)
{
charaClass = "Swordmaster";
charaStr = 10;
charaDex = 6;
charaInt = 4;
charaAgi = 6;
charaVit = 4;
}
else if (charaChoice == 2)
{
charaClass = "Warlock";
charaStr = 1;
charaDex = 10;
charaInt = 14;
charaAgi = 3;
charaVit = 2;
}
else if (charaChoice == 3)
{
charaClass = "Exorcist";
charaStr = 1;
charaDex = 7;
charaInt = 10;
charaAgi = 4;
charaVit = 8;
}
else if (charaChoice == 4)
{
charaClass = "Rouge";
charaStr = 3;
charaDex = 10;
charaInt = 4;
charaAgi = 12;
charaVit = 1;
}
else
{
charaClass = "Sniper";
charaStr = 1;
charaDex = 12;
charaInt = 4;
charaAgi = 12;
charaVit = 1;
}
//Print out the character sheet for the user to see
cout << "\nHere is your Character Sheet!\n" << endl;
cout << "Characters Name: " << charaFirstName << " " << charaLastName << endl;
cout << "Class: " << charaClass << endl;
cout << "Strength: " << charaStr << endl;
cout << "Dexterity: " << charaDex << endl;
cout << "Intelligence: " << charaInt << endl;
cout << "Agility: " << charaAgi << endl;
cout << "Vitality: " << charaVit << endl;
//Present user with enemies to test out there character against
cout << "\nNow that you have created your own character, it's time to test them out!\n" << endl;
cout << "Choose from one of the enemies below to pit your character against them:\n" << endl;
cout << "1. Grue" << endl;
cout << "2. Mind Flayer" << endl;
cout << "3. Giant" << endl;
cout << "4. Golem" << endl;
cout << "5. Drow\n" << endl;
cout << "Please choose an enemy, and then enter the number of your chosen enemy: ";
cin >> charaChoice;
cout << "\n";
//Calculate whether or not the character wins against said monster and print output
if (charaChoice == 1)
{
if (charaStr > 2)
{
cout << "You have eaten the Grue!";
}
else
{
cout << "The Grue has eaten you...";
}
}
else if (charaChoice == 2)
{
if (charaInt > 5)
{
cout << "You roasted the Mindflayers brain!";
}
else
{
cout << "You were served with a nice Chianti and some fava beans...";
}
}
else if (charaChoice == 3)
{
if (charaDex > 6)
{
cout << "You were able to topple the Giant!";
}
else
{
cout << "Fi, fie, fo, fum you're on the bottom of a Giant's shoe, next to some gum...";
}
}
else if (charaChoice == 4)
{
if (charaVit > 5)
{
cout << "Looks like you smashed the Golem to pieces!";
}
else
{
cout << "Unfortunately the Golem put you six feet under...";
}
}
else
{
if (charaAgi > 5)
{
cout << "The lame Drow was easily sliced and diced by your superior speed!";
}
else
{
cout << "Looks like you were too slow, Drizzt wins this day...";
}
}
return 0;
}Here is the awesome part 3 of my assignment XD.
I had to use two different types of variables, and chained as well as nested if else statements.

