/* Program Name: User Inventory Process: ??? Function Input/Parameters: ??? Function Output/Parameters: ??? Function Output/Returned: ??? Device Input/Device: ??? Device Output/Monitor: ??? Dependencies: ??? */ #include #include #include #include #include #include #include #include using namespace std; // class definitions class Character { private: string characterName; int characterAge; public: Character() { characterName = "'Character'"; characterAge = 1; } Character(string name, int age) { characterName = name; characterAge = age; } ~Character() { // } // accessor functions void print() { cout << "Character " << characterName << ": " << endl; cout << "\tIs age: " << characterAge << ". " << endl; } string getName() { return characterName; } int getAge() { return characterAge; } // mutator functions void setName(string name) { characterName = name; } void setAge(int age) { characterAge = age; } }; class Hero : public Character { private: int heroHitPoints; string heroSuperpower; public: Hero() : Character() { heroHitPoints = 1; heroSuperpower = "'Flight'"; } Hero(string name, int age, int hitPoints, string superpower) : Character(name, age) { heroHitPoints = hitPoints; heroSuperpower = superpower; } ~Hero() { // } // accessor functions void print() { cout << "Hero " << getName() << ": " << endl; cout << "\tHit Points: " << heroHitPoints << ". " << endl; cout << "\tSuperpower: " << heroSuperpower << ". " << endl; } int getHitPoints() { return heroHitPoints; } string getSuperpower() { return heroSuperpower; } // mutator functions void setHitPoints(int hitPoints) { heroHitPoints = hitPoints; } void setSuperpower(string superpower) { heroSuperpower = superpower; } }; class Enemy : public Character { private: int enemyHitPoints; string enemyWeapon; public: Enemy() : Character() { enemyHitPoints = 1; enemyWeapon = "'Club'"; } Enemy(string name, int age, int hitPoints, string weapon) : Character(name, age) { enemyHitPoints = hitPoints; enemyWeapon = weapon; } ~Enemy() { // } // accessor functions void print() { cout << "Enemy " << getName() << ": " << endl; cout << "\tHit Points: " << enemyHitPoints << ". " << endl; cout << "\tWeapon : " << enemyWeapon << ". " << endl; } int getHitPoints() { return enemyHitPoints; } string getEnemyWeapon() { return enemyWeapon; } // mutator functions void setHitPoints(int hitPoints) { enemyHitPoints = hitPoints; } void setEnemyWeapon(string weapon) { enemyWeapon = weapon; } }; // function definitions // main function int main() { // test values to make sure paramters were working // Character automaticCharacter("Ryan Reynolds", 25); // Hero automaticHero("Dazzling Dash", 27, 300, "Super Speed"); // Enemy automaticEnemy("Wicked Witch", 216, 315, "Magic"); string charName; int charAge; int charHitPoints; string charPower; // empty line on purpose Character manualCharacter; Hero manualHero; Enemy manualEnemy; // temp stuff for the entries string tempString; int tempInt; // ask user for input of the objects // first, characters cout << "Enter in a new character: " << endl; cout << "Name First: "; getline(cin, tempString); // cout << endl; manualCharacter.setName(tempString + " - Manual Entry"); charName = tempString; cout << "Age Second: "; cin >> tempInt; cin.ignore(); cout << endl; manualCharacter.setAge(tempInt); charAge = tempInt; Character automaticCharacter(charName + " - Parameterized", charAge); // next, heroes cout << "Enter in a new hero: " << endl; cout << "Name First: "; getline(cin, tempString); // cout << endl; manualHero.setName(tempString + " - Manual Entry"); charName = tempString; cout << "Age Second: "; cin >> tempInt; cin.ignore(); // cout << endl; manualHero.setAge(tempInt); charAge = tempInt; cout << "Hit Points Third: "; cin >> tempInt; cin.ignore(); // cout << endl; manualHero.setHitPoints(tempInt); charHitPoints = tempInt; cout << "Superpower Last: "; getline(cin, tempString); cout << endl; manualHero.setSuperpower(tempString); charPower = tempString; Hero automaticHero(charName + " - Parameterized", charAge, charHitPoints, charPower); // next, enemies cout << "Enter in a new enemy: " << endl; cout << "Name First: "; getline(cin, tempString); // cout << endl; manualEnemy.setName(tempString + " - Manual Entry"); charName = tempString; cout << "Age Second: "; cin >> tempInt; cin.ignore(); // cout << endl; manualEnemy.setAge(tempInt); charAge = tempInt; cout << "Hit Points Third: "; cin >> tempInt; cin.ignore(); // cout << endl; manualEnemy.setHitPoints(tempInt); charHitPoints = tempInt; cout << "Weapon Last: "; getline(cin, tempString); cout << endl; manualEnemy.setEnemyWeapon(tempString); charPower = tempString; Enemy automaticEnemy(charName + " - Parameterized", charAge, charHitPoints, charPower); // print out the objects automaticCharacter.print(); cout << endl; automaticHero.print(); cout << endl; automaticEnemy.print(); cout << endl; manualCharacter.print(); cout << endl; manualHero.print(); cout << endl; manualEnemy.print(); cout << endl; // return zero (end program) return 0; }