note:c++ code, please make it simple code ,for beginner. Create a new class that
ID: 3737632 • Letter: N
Question
note:c++ code, please make it simple code ,for beginner.
Create a new class that inherits the character class for an enemy
e.g., a “Dragon” class that extends the character class
In the new class, create a function that provides an alternate attack for this enemy
e.g., a breathe fire attack that inflicts extra damage
In your class' getAction() implementation, have the new enemy class use it’s alternate attack 30% of the time
Set up rand() to generate a number 1-100 and if the value is below 30, have the enemy use its special move
Explanation / Answer
class SuperDragon : public Dragon { // inherit your enemy
void superAction() { //define your enemy’s super power here
std::cout << “a breathe fire attack ”
}
void getAction() { //determines the random number and call the super action
srand (time(NULL));
double random = rand() %100 + 1;
if (random < 30)
superAction();
}
}
Remember to #include
cstdlib
cstdtime
This is the simplest code I could do for you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.