Starting from:

$25

CSCI251-Assignment 2 Solved

For this assignment, you are required to write C++ codes to represent a simple application for a fantasy roleplaying game. In this game, you have four different type of creatures: wizard, elf, dwarf, and demon. Each creature has attributes to represent its name, strength and hit points. The strength is used to measure how much damage this creature can inflict on others while the hit points is to represent how much damage this creature can sustain.  

 

In a particular game, when a creature attacks, we can request to get the damage value the creature can inflict. Your program should decide on the general strength and hit point value when a creature is created and this will be the initial value for all creatures.  

 

The damage value is determined by its strength. However, the damage can be more depending on the type of the creature. Demons can inflict 50 additional damage with a 5% chance. Dwarf inflict double damage with a 10% chance while Elf are fast enough that they get to attack twice. Wizard can inflict magical damage that causes their opponent to miss their next attack with either 50% chance if no wand is used or 90% chance when a wand is being used.

 

Every time a creature is attacked, the hit points are reduced based on the damage caused by the creature attacking it. If the hit points reaches 0 or less, the creature is pronounced dead and the object representing the creature should be destroyed. There can be more than one type of creature in a game played.  

 

Your application should allow several games played one after another. In each game, the user may select any two creatures to be created and and fight. The winner may stand a chance to fight another chosen opponent or the user may choose to quit the game.  

 

The following are the requirements that must be implemented in the application

 

-      Design and implement classes using inheritance to represent the creatures. The base class should be made abstract. Identify the suitable attributes for each classes. All derived classes must have unique attributes apart from the attributes inherited from the base class. Identify and implement suitable constructors, accessors, mutators, and also abstract method(s).  

-      You must also include suitable overloaded operators to your classes. At least three different overloaded operators should be used.

-      There must be at least one friend function declared.

-      Polymorphism must be implemented. To do this, all the creatures created must be stored in a single array. There must be demonstration on the use of polymorphic call and also dynamic cast in your application.

 

You are free to demonstrate how the game can be played. However, the following should be present in some ways:

 

-      Status of each creature (or at least the creatures involved in the current fight)

-      The attacking creature and the creature being attacked

-      The damage value when an attack is made

-      The winning creature

-      The creature that is destroyed

More products