diff --git a/assignmentThree/characters b/assignmentThree/characters index 9e85f42..352204e 100755 Binary files a/assignmentThree/characters and b/assignmentThree/characters differ diff --git a/assignmentThree/characters.cpp b/assignmentThree/characters.cpp index 3495e63..e61c3a8 100644 --- a/assignmentThree/characters.cpp +++ b/assignmentThree/characters.cpp @@ -24,16 +24,138 @@ using namespace std; class Character { private: - /* data */ + string characterName; + int characterAge; public: - Character(/* args */) + 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 @@ -41,6 +163,103 @@ public: // 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; }