Page 1 of 1

Create a class Pokemon that represents characters in a game. The class has the following data and behavior: Field/Constr

Posted: Sun May 15, 2022 12:27 pm
by answerhappygod
Create A Class Pokemon That Represents Characters In A Game The Class Has The Following Data And Behavior Field Constr 1
Create A Class Pokemon That Represents Characters In A Game The Class Has The Following Data And Behavior Field Constr 1 (126.81 KiB) Viewed 81 times
Create a class Pokemon that represents characters in a game. The class has the following data and behavior: Field/Constructor/Method Description private String name name of the Pokemon, such as "Pikachu" private boolean aggressive true if this Pokemon likes to fight private int attack attack power of the Pokemon private int defense defense power of the Pokemon public Pokemon(String name, boolean aggressive, int attack, int defense) makes a Pokemon with the given attributes public int getAttack() returns the Pokemon's attack power public int getDefense() returns the Pokemon's defense power public String getName() returns the Pokemon's name public boolean isAggressive() returns true if the Pokemon likes to fight, and false if he is defensive Modify the class to be comparable by adding an appropriate compareTo method. All defensive Pokemon are considered to be "less than" aggressive Pokemon. A defensive Pokemon is considered to be "less than" another if it has a lower defense power. An aggressive Pokemon is considered to be "less than" another if it has a lower sum of attack and defense power. If two Pokemon are both aggressive or defensive and have the same defense or attack+defense power, they are considered to be "equal." Your method should not modify any Pokemon object's state. You may assume the parameter passed is not null.