Question
Pokmon GO continues to be one of the highest grossing mobilegames. In the game, you encounter wild pokemon, which you can attempt to catch. Each
Pokémon GO continues to be one of the highest grossing mobilegames. In the game, you
encounter wild pokemon, which you can attempt to catch. Each gamefor Pokemon uses
slightly different rules for catching. Generally the user throws aball, and has a chance of
catching the Pokemon. There are better balls which increase yourchances, there are also
items you can give the Pokemon (berries) which increase thelikelihood of catching, finally the
way you throw the ball can increase your chances. In the end, allthese factors are plugged
into the unified catch formula. This formula gives a number between0 and 1. The computer
picks a random number between 0 and 1, if the picked number islower than the formula
number, you caught the pokemon, if not, you didn’t.
For this assignment you’ll be implementing the encounter and catchmechanism as well as the
Pokedex features where you store the pokemon you catch.
? Create a class called Pokemon
? It must have a private integer called level
? It must have a private double called baseCatchRate.
? A constructor which takes in a new level (int) and a newbaseCatchRate (double)
and sets the two class attributes.
? A method getLevel() which returns an int (the currentlevel)
? A method getBaseCatchRate() which returns a double (the basecatch rate).
? Create a class called Bulbasaur which inherits from Pokemon
? It must have a constructor which takes in a level and calls theparent constructor
passing it the level, and 0.2 (which is the base catch rate (20%)for a Bulbasaur).
? It must have an override of toString (java) or ToString (C#)which returns the
string “A level x Blubasaur”. Where x is the correct level of thisobject.
? Create a class called Caterpie which inherits from Pokemon
? It must have a constructor which takes in a level and calls theparent constructor
passing it the level, and 0.5 (which is the base catch rate (50%)for a Caterpie).
? It must have an override of toString (java) or ToString (C#)which returns the
string “A level x Caterpie”. Where x is the correct level of thisobject.
? Create a class called Charmander which inherits fromPokemon
? It must have a constructor which takes in a level and calls theparent constructor
passing it the level, and 0.2 (which is the base catch rate (20%)for a
Charmander).
? It must have an override of toString (java) or ToString (C#)which returns the
string “A level x Charmander”. Where x is the correct level of thisobject.
? Create a class called Pokedex.
? It must have a private ArrayList (Java)/List (C#) calledmyPokedex of Pokemon.
? It must have a method called addToDex which takes in a Pokemonand adds it to
the myPokedex ArrayList/List.
? It must have an override of toString (Java)/ToString (C#) whichreturns all the
pokemon in the pokedex. They should be returned one Pokemon perline, using
the toString/ToString in the respective Pokemon classes.
? In your Main Object, you’ll need to create:
? A method called spawn(). It will take in no parameters, and willreturn a
Pokemon.
? Start by picking a random number between 0 and 20. This will bethe
level
? Next pick a random number between 0 and 3. If this number is 1you’ll
spawn a new Bulbasaur. If this number is 2, you’ll spawn anew
Charmander. If this number is anything else, you’ll spawn a newCaterpie.
? Hint you’ll need to utilize polymorphism when creating thisencounter
pokemon.
? Print out a statement like “You encounter A level 3 Bulbasaur”.Obviously
replace the level and pokemon name with the appropriate answer forwhat
you’ve picked.
? A method called throwBall() which takes no parameters and returnsa float.
? Ask the user what type of ball they wish to use? (Poke, Great,Ultra).
? Read in and store their answer.
? If they choose a Poke ball, set ballMultiplier (a float) to1.
? If they choose a Great ball, set ballMultiplier to 1.5
? If they choose an Ultra ball, set ballMultiplier to 2
? Next ask what berry they wish to use (None, Razz,SilverPinap,
GoldenRazz)
? If they choose Razz, set berryMultiplier (a float) to 1.5
? If they choose SilverPinap, set berryMultiplier to 1.8
? If they choose GoldenRazz, set berryMultiplier to 2.5
? Otherwise set berryMultiplier to 1.
? Finally ask them if it’s a curveball (Yes or No).
? If they choose Yes, set curveMultiplier to 1.7.
? Otherwise set curveMultiplier to 1.
? Multiply the 3 numbers together (ballMultiplier, berryMultiplierand
curveMultiplier) and return the value.
? Write a main method as follows:
? Create an instance of Pokedex called myDex
? Call your Spawn method, and get a new encounter pokemon.
? Using a loop, you’ll keep asking them which ball to throw untilthey catch
the pokemon.
? First set an attribute called cpm to 0.49985844
? In case you are wondering, this number is related to thelevel
of the pokemon, we are always assuming a level 14
pokemon with this number.
? Next call your throwBall() method. It returns a multiplier thatyou’ll
need in a moment.
? Calculate the catchProbability. Use this formula:
? BCR is the baseCatchRate from the encountered Pokemon.
? Multipliers is what you got back from throwBall() method
above.
? Pick a random number between 0 and 1.
? If this number is lower than the catchProbability they have
successfully caught the pokemon. If not, the pokemon
jumped out of the ball.
? If they caught the pokemon, print out a line like “A level10
Bulbasaur Caught”. Be sure the level and name of pokemon
are correct. Then add the pokemon to the user’s pokedex.
? If they didn’t catch the pokemon, print out a line like “OopsA
level 10 Bulbasaur jumped out, try again!. Then go back to
the top of your catch loop and repeat all the steps untilthey
catch it.
? After each successful catch, ask the user if they’d like tocontinue catching
pokemon. As long as they say yes, spawn a new pokemon, and letthem
try to catch it.
? Once they say No (they would not like to keep catching pokemon),print
out all the pokemon in their pokedex.
Sample Output: (bold = input)
[Note, the types and levels of pokemon you’ll encounter are random,so your output will differ.
Also note that catching a pokemon is random too, so you may have totry multiple times to
catch one, even with Ultra balls, and GoldenRazz berries andCurveThrows, they just make it
more likely you’ll catch it]
You encounter A level 6 Charmander
What type of ball do you wish to use? (Poke, Great, Ultra)
Poke
What berry do you wish to use? (None, Razz, SilverPinap,GoldenRazz)
None
Is this a curveball? (Yes or No)
No
Oops, A level 6 Charmander jumped out, try again!
What type of ball do you wish to use? (Poke, Great, Ultra)
Ultra
What berry do you wish to use? (None, Razz, SilverPinap,GoldenRazz)
GoldenRazz
Is this a curveball? (Yes or No)
Yes
Oops, A level 6 Charmander jumped out, try again!
What type of ball do you wish to use? (Poke, Great, Ultra)
Ultra
What berry do you wish to use? (None, Razz, SilverPinap,GoldenRazz)
GoldenRazz
Is this a curveball? (Yes or No)
Yes
A level 6 Charmander Caught!
Continue Catching Pokemon? (Y or N)
Y
You encounter A level 2 Caterpie
What type of ball do you wish to use? (Poke, Great, Ultra)
Poke
What berry do you wish to use? (None, Razz, SilverPinap,GoldenRazz)
None
Is this a curveball? (Yes or No)
No
Oops, A level 2 Caterpie jumped out, try again!
What type of ball do you wish to use? (Poke, Great, Ultra)
Poke
What berry do you wish to use? (None, Razz, SilverPinap,GoldenRazz)
None
Is this a curveball? (Yes or No)
No
A level 2 Caterpie Caught!
Continue Catching Pokemon? (Y or N)
N
You have the following pokemon:
A level 6 Charmander
A level 2 Caterpie
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautilArrayList import javautilList import javautilRandom import javautilScanner class Pokemon private int level private double baseCatchRate public Pokemonint level double baseCatchRate this...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