-
Notifications
You must be signed in to change notification settings - Fork 20.7k
Added surfaceAreaPyramid_v4 with improved comments and validation #6896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Added surfaceAreaPyramid_v4 with improved comments and validation #6896
Conversation
|
This update introduces a new method named surfaceAreaPyramid to the Area.java class. The method calculates the total surface area of a pyramid with a square base by combining the base area and the lateral triangular faces. It includes clear inline comments and follows proper Java naming and formatting conventions. The code validates both input parameters to ensure positive values, using IllegalArgumentException for invalid inputs. Documentation is provided in Javadoc format, describing the parameters, return value, and potential exceptions. This commit was created as part of ENGG*4450 Lab 6 to demonstrate the Git branching, committing, and pull request workflow. The work was completed individually and verified to compile successfully. The feature branch feature/surfaceAreaPyramid_v4 was pushed to GitHub and opened as a pull request for review and potential merge into the main branch. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6896 +/- ##
============================================
- Coverage 78.00% 77.96% -0.04%
Complexity 6444 6444
============================================
Files 737 737
Lines 21519 21526 +7
Branches 4208 4209 +1
============================================
- Hits 16785 16783 -2
- Misses 4062 4070 +8
- Partials 672 673 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new method is correctly implemented and aligns with existing project style guidelines.
All formulas and variable names are accurate and consistent. Validation logic prevents invalid inputs,
and inline comments improve clarity for future developers.
In GitHub, the Files changed tab was used to add these line comments individually.
The pull request was then reviewed using the Review changes -> Comment option to provide
overall feedback confirming that the implementation was correct and ready for merge.
| } | ||
|
|
||
| // Base area (square) = side² | ||
| double baseArea = sideLength * sideLength; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple and efficient calculation of the square base area.
Variable naming (baseArea) is clear and self-explanatory.
| double baseArea = sideLength * sideLength; | ||
|
|
||
| // Lateral area = 2 × side × slant height | ||
| double lateralSurfaceArea = 2 * sideLength * slantHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accurate computation for the combined area of four triangular sides.
The inline comment clarifies why the factor of 2 is used instead of 4 × ½ × base × height.
| return Math.PI * radius * (radius + Math.pow(height * height + radius * radius, 0.5)); | ||
| } | ||
| /** | ||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix the spacing issue in the code
clang-format -i --style=file path/to/your/file.java