SHARE
TWEET

Untitled

a guest Jun 10th, 2019 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package PokemonTrainer;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.function.UnaryOperator;
  6. import java.util.stream.Collectors;
  7.  
  8. public class Trainer {
  9.     private int numOfBadges;
  10.     private List<Pokemon> pokemons;
  11.  
  12.     public Trainer() {
  13.         this.numOfBadges = 0;
  14.         this.pokemons = new ArrayList<>();
  15.     }
  16.  
  17.     public void addPokemon(Pokemon pokemon) {
  18.         this.pokemons.add(pokemon);
  19.     }
  20.  
  21.     public void setNumOfBadges() {
  22.         this.numOfBadges++;
  23.     }
  24.  
  25.     public List<Pokemon> getPokemons() {
  26.         return new ArrayList<>(this.pokemons);
  27.     }
  28.     public int pokeCollectionSize() {
  29.         return this.pokemons.size();
  30.     }
  31.  
  32.     private UnaryOperator<Pokemon> damagePokemon = pokemon ->
  33.             new Pokemon(pokemon.getName(), pokemon.getElement(), pokemon.getHealth() - 10);
  34.  
  35.     public void missingPokemonPenalty() {
  36.         this.pokemons = this.pokemons
  37.                 .stream()
  38.                 .map(damagePokemon)
  39.                 .filter(pokemon -> pokemon.getHealth() > 0)
  40.                 .collect(Collectors.toList());
  41.     }
  42.  
  43.     public int getNumOfBadges() {
  44.         return numOfBadges;
  45.     }
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top