Class Pokemon
- java.lang.Object
-
- Pokemon
-
public class Pokemon extends java.lang.Object
Class that implements a Pokemon.Let's play Pokemon! This is our Pokemon class. Each Pokemon has several member variables that make it a Pokemon. Each Pokemon has:
- a name
- a number of hit points that decrement as the game continues
- up to 50 points to split between attack and defense
- a 6-sided dice for calculating attack damage
- a 20-sided die for calculating attack bonuses and defense bonuses
Have a look through the Pokemon file to see how we can construct objects, can use member variables of these objects, and use objects of the same type to make our game.
- See Also:
- Lab 4 Description
-
-
Constructor Summary
Constructors Constructor Description Pokemon()
Create a new Pokemon with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
attack(Pokemon opponent)
Attack another Pokemon.
-
-
-
Method Detail
-
attack
public boolean attack(Pokemon opponent)
Attack another Pokemon.Calling this method will cause this Pokemon to attack another Pokemon as follows:
- We get the attack bonus and defense bonus.
- We roll the d6 die 3 times to calculate the damage.
- We then compare to see if the attack hit or missed, and see if this was a fatal attack.
- Parameters:
opponent
- the Pokemon to attack- Returns:
- whether or not the game has ended
-
-