The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 313 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
This question is about java method. Please see the source code.
1. implement the getEffectiveness method on the Move class.
 2. how a type of a Move affects a type of a Pokemon see this chart: http://bulbapedia.bulbagarden.net/wiki/Type/Type_chart (Attack types are on the left and defending types are on the top.) Use whatever generation you see fit.
3. design this in various ways. free to choose any design best fits. Below are some of possible ways to implement the method.
Design 1 - Hard-coding the Type relationship
write a giant chain of if else statements. For example, since normal type of attack has multiplier of 1 against normal type of pokemon, the method would contain a if statement checking if move and pokemon both have "NORMAL" type and return 1. And there would be such statement for all possible combinations
Design 2 - Pokemon Type interface
Similar to the Rock Paper Scissors example, instead of using Enumeration to represent Types, create a Type interface and 15 different Type classes the inherit from the Type interface, e.g. Normal would be a class that implements Type interface. And have those individual classes have a method that determine its effectiveness against other Types. And the getEffectiveness method would use the Type classes do the work of determining the effectiveness.
Design 3 - Pokemon Type Chart datatype
Create a set of lookup tables (HashMap) that returns the effectiveness between two types. For example: Map normalAttack = new HashMap<>();
normalAttack.put(Type.NORMAL, 1);
normalAttack.put(Type.ROCK, 0.5);
Design 4: free choice
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly