Implement the getEffectiveness method on the Move class Solved

30.00 $ 15.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment

Description

5/5 - (1 vote)
  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