Пример #1
3
  public void testGetScoreValue() {
    Balloon testBalloon = new Balloon(1000, 1000, -1, 0);

    assertEquals(
        "Test Failure: Points not based on constant", Balloon.VALUE, testBalloon.getScoreValue());
  }
Пример #2
0
  public void testGetImage() {
    Balloon testBalloon = new Balloon(1000, 1000, -1, 0);

    assertTrue(
        "Test Failure: Balloon Image is not consistent with theme",
        theme.getBalloon(0).equals(testBalloon.getImage(theme)));
  }
Пример #3
0
  public static void main(String[] args) {
    Balloon balloon1 = new Balloon(3);

    System.out.println("Before Inflation: " + balloon1.getVolume());
    balloon1.inflate(3);
    System.out.println("After Inflation: " + balloon1.getVolume());
  }
Пример #4
0
  public void testGetImageWhenPopped() {
    Balloon testBalloon = new Balloon(1000, 1000, -1, 0);

    testBalloon.popped = true;

    assertTrue(
        "Test Failure: Popped Image is not consistent with theme",
        theme.getPoppedBalloon(0).equals(testBalloon.getImage(theme)));
  }
Пример #5
0
 private void RemoveBalloonsOutsideOfCanvas() {
   Vector<Balloon> balloons = (Vector<Balloon>) Balloons.clone();
   for (int i = 0; i < Balloons.size(); i++) {
     Balloon b = balloons.elementAt(i);
     if (!IsBalloonInCanvas(b)) {
       b.IsAlive = false;
       Balloons.remove(b);
     }
   }
 }
Пример #6
0
  public void Update() {
    for (Vec2 pos : AddingPositions) {
      int colorIndex = (int) Math.round(Math.random() * (balloonColors.size() - 1));
      TryAddBalloonAt(pos, new Vec2(0, 1), balloonColors.elementAt(colorIndex));
    }

    for (Balloon b : Balloons) {
      b.Update();
    }

    RemoveBalloonsOutsideOfCanvas();
  }
Пример #7
0
  public void testMoveFallOffTop() {
    Balloon dummyBalloon = new Balloon(0, 0, -1, 0);

    Bitmap image = dummyBalloon.getImage(theme);
    Balloon testBalloon = new Balloon(0, -1 * image.getHeight(), -1, 0);

    testBalloon.move(theme, 1, 1);

    assertFalse("Test Failure: Balloon should not pop when floating off top", testBalloon.popped);
    assertTrue(
        "Test Failure: Balloon should show as offscreen when it floats too high",
        testBalloon.offScreen);
  }
Пример #8
0
  public void testMove() {
    Balloon testBalloon = new Balloon(600, 600, -1, 0);

    int oldXCoordinate = testBalloon.xCoordinate;
    int oldYCoordinate = testBalloon.yCoordinate;
    testBalloon.move(theme, 1000, 1000);

    assertEquals(
        "Test Failure: xCoordinate does not match expected value after move",
        oldXCoordinate,
        testBalloon.xCoordinate);
    assertEquals(
        "Test Failure: yCoordinate does not match expected value after move",
        oldYCoordinate - 1,
        testBalloon.yCoordinate);
    assertEquals(
        "Test Failure: yVelocity does not match expected value after move",
        -1,
        testBalloon.yVelocity);
    assertFalse("Test Failure: Balloon should not pop when moved", testBalloon.popped);
    assertFalse("Test Failure: Balloon should not go offscreen when moved", testBalloon.offScreen);
  }
Пример #9
0
 public static void main(String[] args) {
   // Create an array of balloons
   Balloon[] thing = new Balloon[500];
   // build the first balloon
   thing[0] = new Balloon();
   System.out.println(thing[0]);
   // build the second balloon
   thing[Balloon.getQuantity()] = new Balloon(12, "white");
   // build the third balloon
   thing[Balloon.getQuantity()] = new Balloon(6, "yellow");
   // print the number of balloons made today
   System.out.printf("Number of balloons made = %d%n", Balloon.getQuantity());
   // Destruct the balloon
   Balloon.destruct(1, thing);
   // print the number of balloons remaining
   System.out.printf("Number of balloons made = %d%n", Balloon.getQuantity());
   // Show the Balloons' characteristics
   // each is the pointer
   for (Balloon each : thing) {
     // only shows the object if it is defined
     if (each != null) System.out.println(each);
   }
 }
Пример #10
0
  public void testGettingSameImage() {
    Balloon testBalloon = new Balloon(1000, 1000, -1, 0);

    Bitmap originalImage = testBalloon.getImage(theme);
    testBalloon.move(theme, 1, 1);
    Bitmap nextImage = testBalloon.getImage(theme);
    assertEquals(
        "Test Failure: Images should not change for poppable objects", originalImage, nextImage);

    testBalloon.move(theme, 1, 1);
    nextImage = testBalloon.getImage(theme);
    assertEquals(
        "Test Failure: Images should not change for poppable objects", originalImage, nextImage);

    testBalloon.move(theme, 1, 1);
    nextImage = testBalloon.getImage(theme);
    assertEquals(
        "Test Failure: Images should not change for poppable objects", originalImage, nextImage);

    testBalloon.move(theme, 1, 1);
    nextImage = testBalloon.getImage(theme);
    assertEquals(
        "Test Failure: Images should not change for poppable objects", originalImage, nextImage);
  }
Пример #11
0
 public void Render() {
   for (Balloon b : Balloons) {
     b.Render();
   }
 }
Пример #12
0
 private Balloon getBalloonWithFixedY(double y) {
   Balloon result = simple.getBalloonWithFixedY(y);
   result = result.rotate(rotationInverse);
   result = result.translate(translateO);
   return result;
 }