Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with my CS 172 homework. Introduction In this assignment, we will build another small piece of a game. This assignment focuses on combat

Need help with my CS 172 homework.

Introduction

In this assignment, we will build another small piece of a game. This assignment focuses on combat between a player and series of monsters. Inheritance will be required to make all the monsters different without changing how battles work.

In this game a hero will encounter and fight a series of enemies.

NOTE: The description below is a bare minimum requirement specification. As your final assignment, you have a lot of implementation freedom and hope you have fun thinking about things like pass/return by reference, const parameters/functions, data types, enumeratrion, classes, encapsilation, overloading, inheritance, dynamic memory, etc.. We want to get used to good design and implementation decisions early and often!

Part 1: The Enemy

Make an enemy class. This will be the parent class of every monster our hero has to fight. It will supply the minimum functions that are needed for a monster to exist in the game.

This is an abstract class, all your methods (with the exception of the constructor) should be virtual and set =0.

A good starting point for you enemy class is as follows:

A way to check how much health the enemy has.

A way to damage the enemy.

An attack method for the enemy to damage another enemy.

A method that prints to the console information about the enemy so the player knows who they are fighting.

The hero will also be a kind of enemy. (It is the enemy to the monsters.)

Part 2: Make Monsters

Create 5 types of monsters, each derived from your Enemy class/interface. All your monsters must meet the following requirements:

Can be defeated.

Can attack an enemy and take damage from and enemy.

Additionally, at least 1 of your monsters MUST have multiple attacks that it decides between at random. HINT: use lab 9 as an example for randomly choosing attacks.

Part 3: Make a Hero

The hero is just a kind of enemy!

Create a hero class that implements the enemy interface. You will need to get input for the user to decide what attack to do.

A hero has the following properties:

A hero has a name, chosen by the player.

A hero has health bar

A hero has 6 potions that each heals some points of damage.

A hero has 10 fireballs, each do damage. (More damage then the sword.)

A hero has a sword that does damage.

A hero has a shield. When the shield is up the hero can't attack but attacks on them only do half damage.

When it is the hero's attack method is called, print out the hero's status and ask for input on which attack to use. Then do what is requested by the player.

The player may quit the game at any time by saying their action is "exit". You will need to use an exception to break out of the code and exit the program when this happens.

Part 4: The Game

Implement a main program that plays the game. The game should go as follows:

Ask for the Hero's name

Ask the user for how many Enemies there will be (you may assume they will enter a positive integer)

Create the number of enemies requested in (2) whose types are randomly selected from your pool of 5 potential enemy types.

For each enemy (you will fight them one at a time)

Print out what monster is attacking

Fight until the enemy or hero is dead

If the monster died, print that out.

Either declare the hero victorious or dead.

A single round of combat should go as follows:

Hero attacks

If the monster is alive, it attacks

Reminder: The player can type exit at any time to throw an exception. If this happens, you should tell the player "Thanks for Playing" and exit the program.

Here is an example of how the game could look with 2 monsters.

Welcome to Adventure Battle! What is the name of your hero? Cloud How many enemies do you want Cloud to battle? 2 You have encountered a Bat! Cloud: 100/100 health Remaining: 10 Fireballs, 6 Potions Enter Command: sword shield fireball potion exit shield Hide Behind Shield! Bat bites you! Cloud: 98/100 health Remaining: 10 Fireballs, 6 Potions Enter Command: sword shield fireball potion exit sword Sword Slash Attack! Bat bites you! Cloud: 93/100 health Remaining: 10 Fireballs, 6 Potions Enter Command: sword shield fireball potion exit sword Sword Slash Attack! Enemy is defeated! You have encountered a Wolf! Cloud: 93/100 health Remaining: 10 Fireballs, 6 Potions Enter Command: sword shield fireball potion exit potion You drank a potion. Wolf scratches you! Cloud: 85/100 health Remaining: 10 Fireballs, 5 Potions Enter Command: sword shield fireball potion exit fireball Fireball Attack Successful! Wolf scratches you! Cloud: 70/100 health Remaining: 9 Fireballs, 5 Potions Enter Command: sword shield fireball potion exit fireball Fireball Attack Successful! Enemy is defeated! You have defeated all enemies and saved the world. Good Job. 

All five of your monsters (h and cpp files) with at least 1 monster that has random attacks.

The hero header and cpp file.

The main file used to implement the game.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How would you advise Lennox to help resolve this lack of diversity?

Answered: 1 week ago