示例#1
0
  @Test
  public void testEnemyHashCode() {
    Enemy enemy1 = new Enemy("Enemy", 10, 100);
    int hashCode = "Enemy".hashCode();

    assertEquals("Wrong hash code", hashCode, enemy1.hashCode());
  }
示例#2
0
  @Test
  public void testMoveEnemy() {
    Enemy enemy = new Enemy("Enemy", 10, 100);

    assertEquals(0, enemy.getYPos());
    enemy.move();
    assertEquals(10, enemy.getYPos());
  }
示例#3
0
  @Test
  public void testEnemyEquals() {
    Enemy enemy1 = new Enemy("Enemy", 10, 100);
    Enemy enemy2 = new Enemy("Enemy", 5, 50);
    Enemy enemy3 = new Enemy("Friend", 10, 100);

    assertTrue(enemy1.equals(enemy2));
    assertFalse(enemy1.equals(enemy3));
  }
示例#4
0
  @Test
  public void testCreateEnemy() {
    Enemy enemy1 = new Enemy("Enemy", 10, 100);
    Enemy enemy2 = new Enemy("SuperMeanGuy", 10, 100);

    assertEquals("Enemy", enemy1.getWord());
    assertEquals(10, enemy1.getSpeed());
    assertEquals(100, enemy1.getXPos());
    assertEquals(0, enemy1.getYPos());
    assertEquals(60, Enemy.getWordWidth(enemy1.getWord()));
    assertEquals(130, Enemy.getWordWidth(enemy2.getWord()));
  }
示例#5
0
  /**
   * Get the enemy's vector and fire a bullet towards it Has cool down time for the bullet. Can fire
   * a bullet every one second
   *
   * @param e
   * @return
   */
  @Override
  public Bullet shootBullet(Enemy e) {

    Point2D p = new Point2D(point);
    p.setX(point.getX() + 50);
    p.setY(point.getY() + 50);
    Bullet bull = new SomeBullet(p);
    bull.setDestination(e.getPoint2D());
    return bull;
  }