Package org.jpokemon.pokemon

Examples of org.jpokemon.pokemon.Pokemon


    if (indexOld < 0 || indexNew < 0 || indexOld >= _amount || indexNew >= _amount)
      throw new IllegalArgumentException("Index out of bounds");
    if (indexOld == indexNew)
      throw new IllegalArgumentException("Arguments are equal");

    Pokemon swap = _data[indexOld];
    int loopUpdateDirection = (indexOld > indexNew) ? -1 : 1;
    for (int i = indexOld; i != indexNew; i = i + loopUpdateDirection) {
      _data[i] = _data[i + loopUpdateDirection];
    }
    _data[indexNew] = swap;
View Full Code Here


  public boolean swap(int p1, int p2) {
    if (p1 < 0 || p2 < 0 || p1 >= _amount || p2 >= _amount) throw new IllegalArgumentException("Index out of bounds");
    if (p1 == p2) throw new IllegalArgumentException("Arguments are equal");

    Pokemon swap = _data[p1];
    _data[p1] = _data[p2];
    _data[p2] = swap;
    _version++;

    return true;
View Full Code Here

    while (_amount > 0)
      remove(0);

    for (XmlNode child : node.getChildren(Pokemon.XML_NODE_NAME)) {
      Pokemon p = new Pokemon(1);
      p.loadXml(child);
      add(p);
    }
  }
View Full Code Here

  public void setUp() {
    unit = new PokemonStorageUnit(size);
  }

  public void testAdd() {
    unit.add(new Pokemon(1));

    assertEquals(1, unit.size());
  }
View Full Code Here

    assertEquals(1, unit.size());
  }

  public void testRemove() {
    Pokemon p = new Pokemon(1);
    unit.add(p);
    unit.remove(p);

    assertEquals(0, unit.size());
  }
View Full Code Here

    assertEquals(0, unit.size());
  }

  public void testGet() {
    Pokemon p = new Pokemon(1);
    unit.add(p);

    assertEquals(p, unit.get(0));
  }
View Full Code Here

    assertEquals(p, unit.get(0));
  }

  public void testSwap() {
    Pokemon p1 = new Pokemon(1);
    Pokemon p2 = new Pokemon(2);
    unit.add(p1);
    unit.add(p2);

    unit.swap(0, 1);
View Full Code Here

    assertEquals(p2, unit.get(0));
  }

  public void testAddLimit() {
    for (int i = 0; i < size + 1; i++)
      unit.add(new Pokemon(i + 1));

    assertEquals(size, unit.size());
  }
View Full Code Here

      assertTrue(e instanceof IllegalArgumentException);
    }
  }

  public void testSwapMany() {
    Pokemon p1 = new Pokemon(1);
    Pokemon p2 = new Pokemon(2);
    Pokemon p3 = new Pokemon(3);
    Pokemon p4 = new Pokemon(4);
    unit.add(p1);
    unit.add(p2);
    unit.add(p3);
    unit.add(p4);
View Full Code Here

      assertTrue(e instanceof IllegalArgumentException);
    }
  }

  public void testSwapSame() {
    Pokemon p1 = new Pokemon(1);
    unit.add(p1);

    try {
      unit.swap(0, 0);
      fail();
View Full Code Here

TOP

Related Classes of org.jpokemon.pokemon.Pokemon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.