Skip to content

Improve pyramid surface area validation and readability - #7670

Open
FarhanQ19 wants to merge 1 commit into
TheAlgorithms:masterfrom
FarhanQ19:lab6-pyramid-area
Open

FarhanQ19 wants to merge 1 commit into
TheAlgorithms:masterfrom
FarhanQ19:lab6-pyramid-area

Conversation

@FarhanQ19

Copy link
Copy Markdown

Updated surfaceAreaPyramid to provide a descriptive error message for invalid side lengths and declared the calculation variables final.

Verified that Area.java compiles successfully using javac with exit code 0. No automated tests were run.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.22%. Comparing base (a7a2441) to head (5f1073d).

Files with missing lines Patch % Lines
src/main/java/com/thealgorithms/maths/Area.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7670   +/-   ##
=========================================
  Coverage     82.21%   82.22%           
- Complexity     8401     8403    +2     
=========================================
  Files           843      843           
  Lines         26141    26141           
  Branches       5100     5100           
=========================================
+ Hits          21493    21495    +2     
  Misses         3854     3854           
+ Partials        794      792    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@FarhanQ19 FarhanQ19 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review completed for this individual lab. I checked input validation, the surface-area calculation, and variable declarations. Area.java compiled successfully with exit code 0; automated tests were not run.

if (slantHeight <= 0) {
throw new IllegalArgumentException("slant height must be greater than 0");
throw new IllegalArgumentException(
"slant height must be greater than 0");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review: The slant-height check rejects zero and negative values. Automated tests should verify that both cases throw IllegalArgumentException.

double baseArea = sideLength * sideLength;
double lateralSurfaceArea = 2 * sideLength * slantHeight;

final double baseArea = sideLength * sideLength;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review: Declaring the calculation variables final makes it clear that they are not reassigned. The surface-area formula remains unchanged.

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