i'm pretty much a beginner / self teaching c++ programmer. i wanted to test my own skills a little bit. i made this program and id be very happy if you guy / girls could tell me how i can improve it. this is my first class (please tell me if you'd like to clean it up a bit)
class race {public:
enum raceOpt { orc, elf, human };
race(raceOpt c_raceOpt, int *STR, int *DEX, int *CON, int *INT, int* WIS, int* CHR);
//race opt outcomes
void ORC(int** STR, int** INT, int** CHR) {
**STR = **STR + 2;
**INT = **INT - 2;
**CHR = **CHR - 2;
}
void ELF(int** DEX) {
//elf code and stat changes
}
//I still have to add human
};
// here's my constructor
race::race(raceOpt c_raceOpt, int* STR, int* DEX, int* CON, int* INT, int* WIS, int* CHR) {
switch (c_raceOpt) {
case orc:
ORC(&STR, &INT, &CHR);
break;
case human:
//human code
break;
case elf:
//elf code
break;
}
}
this is my next base class
class classes {
public:
enum classOpt { fighter, mage, soccerPlayer };
classes(classOpt c_classOpt, double ModStats[_MAX_PATH], int* Sneak, int* Bluff, int* Deplomacy, int* Swim, int* Mana, int* Run);
void Fighter(int** SWIM, int** RUN, int** BLUFF, double ModStats[_MAX_PATH]) {
**SWIM = static_cast<int>(**SWIM + std::round(((ModStats[2] * 2.3))));
**RUN = static_cast<int>(**RUN + (std::round(((ModStats[2] * 2)))));
**BLUFF = static_cast<int>(**BLUFF + std::round(((ModStats[1] * 2.5))));
}
void Mage(int** MANA, int** DEPLOMACY, int** BLUFF, double ModStats[_MAX_PATH]) {
//code to be added
}
void SoccerPlayer(int** RUN, int** SWIM, int** DEPLOMACY, int** SNEAK, double ModStats[_MAX_PATH]) {
//code to be added
}
};
// here's my constructor
classes::classes(classOpt c_classOpt, double ModStats[_MAX_PATH], int* Sneak, int* Bluff, int* Deplomacy, int* Swim, int* Mana, int* Run) {
switch (c_classOpt) {
case fighter:
Fighter(&Swim, &Run, &Bluff, ModStats);
break;
case mage:
Mage(&Mana, &Deplomacy, &Bluff, ModStats);
break;
case soccerPlayer:
SoccerPlayer(&Run, &Swim, &Deplomacy, &Sneak, ModStats);
break;
}
}
and here is my final hero class constructor and main.
class hero {
protected:
int sneak = 0, bluff = 0, deplomacy = 0, swim = 0, mana = 0, run = 0;
int //stats
Str = 16,
Dex = 18,
Con = 11,
Int = 10,
Wis = 8,
Chr = 13;
double modStats[6] = {};
//vvvv gets proper stat mods based on D&D
void getAndSetMods(){
double modStats[6] = {
this->modStats[1] = std::round(Str / 2) - 5,
this->modStats[2] = std::round(Dex / 2) - 5,
this->modStats[3] = std::round(Con / 2) - 5,
this->modStats[4] = std::round(Int / 2) - 5,
this->modStats[5] = std::round(Wis / 2) - 5,
this->modStats[6] = std::round(Chr / 2) - 5,
};//stats above in order
}
public:
void raceAndClass() {
race c_race(race::orc, &Str, &Dex, &Con, &Int, &Wis, &Chr);
getAndSetMods();
classes c_classes(classes::fighter, modStats, &sneak, &bluff, &deplomacy, &swim, &mana, &run);
using
namespace std;
cout << Str << endl << Dex << endl << Con << endl << Int << endl << Wis << endl << Chr << endl;
cout << endl << endl << endl;
cout << sneak << endl << bluff << endl << deplomacy << endl << swim << endl << mana << endl << run << endl;
}
};
int main()
{
hero H;
H.raceAndClass();
while (true);
}