Question: Name the source file for this lab pokemon.cpp. We're going to create a database of Pokemon. C++ doesn't have a built-in Pokemon data type so

Name the source file for this lab pokemon.cpp.

We're going to create a database of Pokemon. C++ doesn't have a built-in Pokemon data type so we'll create our own.

First, we'll create a new data type that represents a Pokemon "Move", some action they do in battle. In your source file, create a new data type called Move that has the following "fields":

- name : A string. - selfHPEffect : An int. - otherHPEffect : An int. - selfAtkEffect : An int. - otherAtkEffect: An int. - selfDefEffect : An int. - otherDefEffect: An int.

With these fields, we can represent moves that hurt or heal Pokemon (others or the owner of the move), and lower/raise the attack/defense of Pokemon. A simple attack move would have a negative value for otherHPEffect because the "effect" of the attack move is to lower some other Pokemon's HP. A simple heal move would have a positive selfHPEffect.

Write a function named simpleAttack, which takes as arguments:

1) A string that represents a move's name. 2) An int that represents the damage an attack move does.

simpleAttack should return a Move value whose name is the string input and whose otherHPEffect is the int input. This function hides all the details of the Move struct from the caller, and makes it simple to get a Move value for the common case of a simple attack move that only hurts the other Pokemon in battle. A more complex attack move would be one where the state of both Pokemon in the battle are affected, for example, an attack that hurts the other Pokemon, but also heals the attacking Pokemon at the same time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!