+1 (315) 557-6473 

Monster attack assignment help sample

Are you required to work on an assignment related to Monster attack? Do you feel like the task is just too difficult for you to work on? Consider taking professional assistance from our programming experts.

Monster Attack

This assignment consists of one main programming task. The purpose of this assignment is to have
you design and implement an object-oriented program in C++, as well as reflect on your approach
and design choices. The assignment comprises the following components:
• A diagram with annotation that describes your object-oriented design
• The completed program
• A 300 word reflection on your program
Assignment Task: Hero’s Quest

Game Overview:

In this assignment, you are to write an action adventure game, where your hero character will fight a
collection of computer-controlled monsters in the grand colosseum. Defeat them all, including the boss, and you will become the grand champion!
Basic Game Play:
In this program, you will control a hero character. Your hero character will fight a series of monsters.
By beating a monster you will earn extra stats and prize money. Eventually you will fight the grand boss monster. Beat the all the monsters and boss without dying and you will become the grand champion! The play will go as follows:
• You are the hero. You have a name (user defined), health (can be between 0 and 50, starts at 20), attack (starts at 3, max is 10), defence (starts at 3, max is 10), and special attack (starts at 2, max is 10). The hero also has an amount of prize money (starts at 0 and has no upper limit).
• In the game there are 5 monsters waiting to fight. They will fight in order. There are 4 regular monsters and finally one boss monster.
• The regular monsters have a name, health (can be between 0 and 100), attack (can be between 0 and 10), and defence (can be between 0 and 10). They do not have a special attack attribute.
• The boss monster has the same attributes as the regular monster but also has a special attack (can be between 0 and 10)
• You will then fight the monsters in order. The fighting process is described separately below.
• When you win a fight, you earn 20 health points, and a random amount of attack, defence, and special points. For each of these you could earn 0, 1 or 2 points. For example after one successful monster battle you might earn 1 attack, 1 defence and 2 special. You also earn prize money, which is how much health you have left at the end of a battle (before adding the 20 health points for winning). This means you earn more prize money if you get less damage during the fight.
• If at any stage your health goes to 0 the game is over and the monsters win.
• If you defeat all monsters and the boss then you win and the game is over.
Monster Stats:
Below are the stats for each monster (health, attack, defence and special for the boss):
• Monster 1: 10 health, 1 attack, 1 defence
• Monster 2: 20 health, 3 attack, 2 defence
• Monster 3: 30 health, 5 attack, 4 defence
• Monster 4: 40 health, 6 attack, 7 defence
• Boss: 50 health, 8 attack, 8 defence, 5 special
Battle:

When you battle a monster, the logic is as follows:

1. The hero generates a random number between 1 and 6. It is added to the skill level.
2. Another random number 1-6 is generated for the monster and added to its defence level.
3. If the player’s attack total is higher than the monsters defence total, the monster loses the difference between the two values in health. If the monsters total is equal or higher, no health is lost.
4. Steps 1 to 3 then occur except with the Monster attacking and Hero defending.
5. Steps 1 to 4 keep continuing until either the player or monster runs out of health.
For example, here is a case with the Hero attacking and Monster defending:
• Hero generates a random number 1 to 6 and adds it to attack. For example, they get a 4 and add it to their attack, which is 3, giving them a total of 7.
• Monster generates a random number 1 to 6 and adds it to defence. For example, they get a 3 and add it to their defence, which is 1, giving them a total of 4.
• As the hero’s score is higher they win the round. They then take 7 – 4 = 3 points off the health of the monster.

Special Attack:

The hero may launch a special attack once per monster fight.
• If the player chooses to do a special attack, they can add their special attack value to their overall attack score, giving them an advantage.
• The player must choose before the attack section of each fight if they wish to do a special attack. They can then not choose to do it again for the rest of a monster fight.

Program Design Diagram:

In this final assignment you are able to design your program in any way you like. You must provide a
diagram with annotation that shows the classes you have in your program and how they interact. It
should contain any relevant notes that describe the classes. This diagram does not have to be formal
UML or any other specific notation, however you may refer to basic class diagram notation.

Program Reflection:

You must provide a 300-word written reflection of your object-oriented design and how well you
believe it was to implement. You should cover the following areas:
• Why you designed it the way you did
• How well you were able to code it, highlighting any issues you found once you tried to implement your design
• How you might change your design to make your solution easier to implement, more efficient, or better for code reuse. 
Solution
BossMonster.cpp 
#include “BossMonster.h”
BossMonster::BossMonster(string name, int health, int attack, intdefence, intspecialAttack)
: PowerCharacter(name, health, attack, defence, specialAttack)
{
}
voidBossMonster::BeforeAttack()
{
if (WasSpecialAttackApplied())
{
return;
}
if (rand() % 2 == 0)
{
ActivateSpecialAttack();
}
}
BossMonster.h
#include “PowerCharacter.h”
classBossMonster : public PowerCharacter
{
public:
BossMonster(string name, int health, int attack, intdefence, intspecialAttack);
protected:
virtual void BeforeAttack() override;
};
Character.cpp 
#include
#include “Character.h”
#include
Character::Character(string name, int health, int attack, intdefence)
: _name(name), _health(health), _attack(attack), _defence(defence)
{}
void Character::StartBattle()
{
}
void Character::EndBattle()
{
}
void Character::Attack(Character* opponent)
{
BeforeAttack();
intattackPoints = _AttackPoints();
intopponentDefencePoint = opponent->_DefencePoints();
cout<
cout<< opponent->GetName() << ” (health = ‘” << opponent->_health << “‘ defence ='” <
if (attackPoints>opponentDefencePoint)
{
opponent->_MakeDamage(attackPoints – opponentDefencePoint);
}
AfterAttack();
}
bool Character::IsAlive()
{
return _health > 0;
}
string Character::GetName()
{
return _name;
}
int Character::_AttackPoints()
{
return _attack + _RandomPoints();
}
int Character::_DefencePoints()
{
return _defence + _RandomPoints();
}
void Character::BeforeAttack()
{
}
void Character::AfterAttack()
{
}
int Character::_RandomPoints()
{
return rand() % RANDOM_POINTS_LIMIT + 1;
}
void Character::_MakeDamage(int damage)
{
cout<
_health = max(0, _health – damage);
cout<< _health << “‘” <
Character.h 
#pragma once
#include
using namespace std;
class Character
{
public:
Character(string name, int health, int attack, intdefence);
public:
virtual void StartBattle();
virtual void EndBattle();
public:
void Attack(Character* opponent);
boolIsAlive();
stringGetName();
protected:
virtualint _AttackPoints();
virtualint _DefencePoints();
protected:
virtual void BeforeAttack();
virtual void AfterAttack();
protected:
int _RandomPoints();
void _MakeDamage(int damage);
protected:
string _name;
int _health;
int _attack;
int _defence;
private:
staticconstint RANDOM_POINTS_LIMIT = 6;
};
CharacterFactory.cpp
#include “CharacterFactory.h”
#include “Hero.h”
#include “Monster.h”
#include “BossMonster.h”
Character* CharacterFactory::CreateHero(string name)
{
int health = 20 + rand() % 30;// can be between 0 and 50, starts at 20
int attack = 3 + rand() % 7; // attack (starts at 3, max is 10)
intdefence = 3 + rand() % 7; // defence (starts at 3, max is 10)
int special = 2 + rand() % 8; // special attack (starts at 2, max is 10)
return new Hero(name, health, attack, defence, special);
}
Character* CharacterFactory::CreateMonster(intnum)
{
switch (num)
{
case 1:
return new Monster(“Monster 1”, 10, 1, 1);
case 2:
return new Monster(“Monster 2”, 20, 3, 2);
case 3:
return new Monster(“Monster 3”, 30, 5, 4);
case 4:
return new Monster(“Monster 4”, 40, 6, 7);
default:
break;
}
returnnullptr;
}
Character* CharacterFactory::CreateBossMonster()
{
return new BossMonster(“Boss”, 50, 8, 8, 5);
CharacterFactory.h
 #pragma once
#include “Character.h”
classCharacterFactory
{
public:
static Character* CreateHero(string name);
static Character* CreateMonster(intnum);
static Character* CreateBossMonster();
private:
CharacterFactory();
};
 Hero.cpp
#include “Hero.h”
#include
Hero::Hero(string name, int health, int attack, intdefence, intspecialAttack)
: PowerCharacter(name, health, attack, defence, specialAttack), _prizeMoney(0)
{
}
void Hero::EndBattle()
{
if (IsAlive())
{
cout<
_prizeMoney += _health;
_health += HEALTH_PRIZE;
_attack += _RandomPrizePoints();
_defence += _RandomPrizePoints();
_specialAttack += _RandomPrizePoints();
cout<< “Score:”;
cout<< ” health(‘” << _health << “‘),”;
cout<< ” attack(‘” << _attack << “‘),”;
cout<< ” special attack(‘” << _specialAttack<< “‘),”;
cout<< ” prize money(‘” << _prizeMoney<< “‘)”;
cout<
}
}
void Hero::BeforeAttack()
{
if (WasSpecialAttackApplied())
{
return;
}
cout<< “Would you like activate special attack? (y/n)”;
char answer;
cin>> answer;
if (answer == ‘y’)
{
ActivateSpecialAttack();
}
}
int Hero::_RandomPrizePoints()
{
return rand() % PRIZE_POINTS_LIMIT;
}
 Hero.h 
#include “PowerCharacter.h”
class Hero : public PowerCharacter
{
public:
Hero(string name, int health, int attack, intdefence, intspecialAttack);
public:
virtual void EndBattle() override;
protected:
virtual void BeforeAttack() override;
private:
int _RandomPrizePoints();
private:
int _prizeMoney;
private:
staticconstint HEALTH_PRIZE = 20;
staticconstint PRIZE_POINTS_LIMIT = 3;
};
HeroQuest.cpp 
// HeroQuest.cpp : Defines the entry point for the console application.
//
#include “stdafx.h”
#include “CharacterFactory.h”
#include
#include
#include
#include
typedefshared_ptrCharacterPtr;
void Fight(CharacterPtr hero, CharacterPtr monster)
{
cout<< “—-Fight started—-” <
cout<< hero->GetName() << ” vs ” << monster->GetName() <
hero->StartBattle();
monster->StartBattle();
while (hero->IsAlive() && monster->IsAlive())
{
hero->Attack(monster.get());
if (monster->IsAlive())
{
monster->Attack(hero.get());
}
}
monster->EndBattle();
hero->EndBattle();
cout<< “—-Fight finished—-” <
}
int main()
{
srand(time(NULL));
stringheroName;
cout<< “Please enter hero name:” <
cin>>heroName;
CharacterPtrhero(CharacterFactory::CreateHero(heroName));
CharacterPtrbossMonster(CharacterFactory::CreateBossMonster());
CharacterPtrmonsters[4];
for (int i = 0; i < 4; i++)
{
monsters[i] = CharacterPtr(CharacterFactory::CreateMonster(i + 1));
}
for (int i = 0; i < 4; i++)
{
Fight(hero, monsters[i]);
if (!hero->IsAlive())
{
break;
}
}
if (hero->IsAlive())
{
Fight(hero, bossMonster);
}
cout<< “—-Game over!—-“<
if (hero->IsAlive())
{
cout<< hero->GetName() << ” defeated all monsters”;
}
else
{
cout<< hero->GetName() << ” was defeated”;
}
return 0;
Monster.cpp 
#include “Monster.h”
Monster::Monster(string name, int health, int attack, intdefence)
: Character(name, health, attack, defence)
{
Monster.h 
#pragma once
#include “Character.h”
class Monster : public Character
{
public:
Monster(string name, int health, int attack, intdefence);
}; 
PowerCharacter.cpp 
#include “PowerCharacter.h”
PowerCharacter::PowerCharacter(string name, int health, int attack, intdefence, intspecialAttack)
: Character(name, health, attack, defence), _specialAttack(specialAttack), _specialAttackActivated(false),
_specialAttackWasApplied(false)
{
}
voidPowerCharacter::StartBattle()
{
_specialAttackWasApplied = false;
}
voidPowerCharacter::ActivateSpecialAttack()
{
if (!_specialAttackWasApplied)
{
_specialAttackActivated = true;
}
}
boolPowerCharacter::WasSpecialAttackApplied()
{
return _specialAttackWasApplied;
}
intPowerCharacter::_AttackPoints()
{
intattackPoints = Character::_AttackPoints();
if (_specialAttackActivated)
{
_specialAttackActivated = false;
_specialAttackWasApplied = true;
attackPoints += _specialAttack;
}
returnattackPoints;
PowerCharacter.h
#pragma once
#include “Character.h”
classPowerCharacter : public Character
{
public:
PowerCharacter(string name, int health, int attack, intdefence, intspecialAttack);
public:
virtual void StartBattle() override;
protected:
voidActivateSpecialAttack();
boolWasSpecialAttackApplied();
protected:
virtualint _AttackPoints() override;
protected:
int _specialAttack;
private:
bool _specialAttackActivated;
bool _specialAttackWasApplied;
}; 
stdafx.cpp 
// stdafx.cpp : source file that includes just the standard includes
// HeroQuest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include “stdafx.h”
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file 
stdafx.h 
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include “targetver.h”
#include
#include
// TODO: reference additional headers your program requires here 
targetver.h
#pragma once
// IncludingSDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include