package hu.bme.mit.spaceship;

import java.util.Random;

/**
* Class storing and managing the torpedoes of a ship
*/
public class TorpedoStore {

  private int torpedos = 0;
  private Random generator = new Random();

  public TorpedoStore(int numberOfTorpedos){
    this.torpedos = numberOfTorpedos;
  }

  public boolean fire(int numberOfTorpedos){
    if(numberOfTorpedos < 1 || numberOfTorpedos > this.torpedos){
      throw new IllegalArgumentException("numberOfTorpedos");
    }

    boolean success = false;

    //simulate random overheating of the launcher bay which prevents firing
    double r = generator.nextDouble();

    if (r > 0.01) {
      // successful firing
      this.torpedos -= numberOfTorpedos;
      success = true;
    } else {
      // failure
      success = false;
    }

    return success;
  }

  public boolean isEmpty(){
    return this.torpedos <= 0;
  }

  public int getNumberOfTorpedos() {
    return this.torpedos;
  }
}

@@ -160,17 +160,21 @@
  torpedo
-s
+Count
  = 0;%0A  
@@ -276,17 +276,21 @@
 .torpedo
-s
+Count
  = numbe
@@ -410,25 +410,29 @@
 this.torpedo
-s
+Count
 )%7B%0A      thr
@@ -702,17 +702,21 @@
 .torpedo
-s
+Count
  -= numb
@@ -887,17 +887,21 @@
 .torpedo
-s
+Count
  %3C= 0;%0A 
@@ -924,24 +924,20 @@
  get
-NumberOf
 Torpedo
-s
+Count
 () %7B
@@ -956,21 +956,25 @@
 this.torpedo
-s
+Count
 ;%0A  %7D%0A%7D%0A

Rename variable torpedos to torpedoCount