Skip to content

Bugfix - #1

Merged
MkDomain merged 4 commits into
mainfrom
bugfix
Oct 13, 2026
Merged

MkDomain merged 4 commits into
mainfrom
bugfix

Conversation

@MkDomain

Copy link
Copy Markdown
Owner

Fixed two critical issues in TorpedoStore and improved performance by making the store reuse the Random generator across function calls.

@MkDomain MkDomain self-assigned this Oct 12, 2026
@MkDomain
MkDomain requested a review from marki-8 October 13, 2026 11:23
public boolean fire(int numberOfTorpedos){
if(numberOfTorpedos < 1 || numberOfTorpedos > this.torpedoCount){
new IllegalArgumentException("numberOfTorpedos");
throw new IllegalArgumentException("numberOfTorpedos");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good work!

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Easy fix!

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rename the Random variable to the original "generator"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

dumb idea

@github-actions

Copy link
Copy Markdown

JAcrGQgSBghbFgtKBQ0N

1 similar comment
@github-actions

Copy link
Copy Markdown

JAcrGQgSBghbFgtKBQ0N

@github-actions

Copy link
Copy Markdown

JAcrGQgSBghbFgtKBQ0N

@sonarqubecloud

Copy link
Copy Markdown

@MkDomain
MkDomain merged commit 88c48a3 into main Oct 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants