Question
Instance Variables There should be 7 instance variables. Please name them exactly as shown String species String name int number String type1 String type2 int
Instance Variables
There should be 7 instance variables. Please name them exactly as shown
String species
String name
int number
String type1
String type2
int hitPnts
int comPwr
These variables represent the fields that are stored in the Pokemon Go game.
species will be the "official" name, like Bulbasaur or Pikachu.
name is for an optional user-defined name. This should never be empty. If the user doesn't specify a name, the name should be set to be the same String as the species.
number will be the official Pokemon number out of the Pokedex.
type1 and type2 will be Pokemon types like water, fire, flying, etc.
hitPnts is the "hit points"
comPwr is the "combat power"
If you are unfamiliar with Pokemon or their properties see for examples: https://www.pokemon.com/us/pokedex/.
Constructors
There should be two constructors.
Takes in 5 parameters: species, name, number, type1, type2
Takes in 4 parameters: species, number, type1, type2
(The 4 parameter constructor should set name to be the same String as species)
The hitPnts and comPwr should be generated automatically within the constructors.
You can make a private helper method that does this part and have the constructors call it, if you know how. This is the most correct way to do this.
The hitPnts should be a random int between 10 and 150 inclusive.
comPwr = (int) (hitPnts * multiplier)Where multiplier is a double between Min=1.00 and Max=3.00
hint: multiplier = Min + (Max - Min)*randGen.nextDouble();
Note: multiplier should not be made an instance variable, neither should the random number generator.
Get Methods
There should be a complete set of Gets methods for all instance variables.
These should be named getSpecies, getName, getNumber, etc. the method names must use get + the exact instance variable name or the jUnit test will not compile.
Set Methods
There should be a completed set of Sets methods for all instance variables.
setName should be the only public set method, the others should be private methods.
These should be named setSpecies, setName, setNumber, ... the method names must use set + the exact instance variable name or the jUnit test will not compile.
PowerUp method
There should be a public void powerUp method that updates both the hitPts and comPwr. It should not take in any parameters/arguments. It will calculate and set new values within the method.
This method can use the setHitPnts and setComPwr methods if you want.
hitPts should be updated like so:
this.hitPnts = this.hitPnts + 1.15 + (0.2 * this.hitPnts)
hitPnts on the right side being the value of this Pokemon's hitPts instance variable before powerUp.
comPwr should be updated using the same formula as in the constructor: (int) (this.hitPnts * multiplier), BUT it should only change comPwr if new value ends up to be higher than the old value.
That it would be less is possible because you must generate a new multiplier each time, if the new one is small, it could actually reduce the output value.
toString method
There should be a toString method that returns a String in this exact form:
Species:Name: Number: Type: | HP: CP:
The name line should not be there if the name is the same as the species.
The vertical bar should not be there if type2 is an empty string.
There is a newline at the end of each line show, including the last one.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started