Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/main/java/hu/bme/mit/spaceship/TorpedoStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
public class TorpedoStore {

//random letrhozasa
Random generator = new Random();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ez jo


// rate of failing to fire torpedos [0.0, 1.0]
private double FAILURE_RATE = 0.0; //NOSONAR

Expand All @@ -30,18 +33,18 @@ public TorpedoStore(int numberOfTorpedos){

public boolean fire(int numberOfTorpedos){
if(numberOfTorpedos < 1 || numberOfTorpedos > this.torpedoCount){
new IllegalArgumentException("numberOfTorpedos");
throw new IllegalArgumentException("numberOfTorpedos");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ez is jo

}

boolean success = false;

// simulate random overheating of the launcher bay which prevents firing
Random generator = new Random();

double r = generator.nextDouble();

if (r >= FAILURE_RATE) {
// successful firing
this.torpedoCount =- numberOfTorpedos;
this.torpedoCount = -numberOfTorpedos;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

es ez is jo

success = true;
} else {
// simulated failure
Expand Down