CSC112 Spring 2016 Examples
#include <iostream>1#include "earthPaca.h"23using namespace std;456//earthPaca::earthPaca(unsigned int pow) : alpaca(pow) {}78std::string9cwillis::earthPaca::name() {10return nickName;11}1213//automate14void15cwillis::earthPaca::act(Alpaca* opponent) {1617if(getHp() > 90 ) {18switch(rand()%4) {19case 0:20earthquake(opponent);21break;22case 1:23fossilize();24break;25case 2:26rockToss(opponent);27break;28case 3:29bury(opponent);30break;31}32} else if (getHp() > 60 and getHp() <= 90) {33if (opponent->getStatus() != STUNNED) {34bury(opponent);35}36else {37earthquake(opponent);38}3940} else if (getHp() > 30 and getHp() >0) {41rockToss(opponent);42}43}4445//moves46void47cwillis::earthPaca::earthquake(Alpaca* opponent) {48cout << name() << " splits the earth with its mighty hooves." << endl;49attack(opponent, 20);50}5152void53cwillis::earthPaca::fossilize() {54cout << name() << " hardens itself." << endl;55increaseDefense(10);56}5758void59cwillis::earthPaca::rockToss(Alpaca* opponent) {60cout << name() << " hurls a rock." << endl;61attack(opponent, 10);62}6364void65cwillis::earthPaca::bury(Alpaca* opponent) {66cout << name() << " pulls its opponent underground." << endl;67stun(opponent, 10);68}6970717273