Skip to content

Commit 545291c

Browse files
JonathanButterworthBorn-as-Harsha
authored andcommitted
docs: Add Javadoc to sorts/BubbleSort.java
1 parent bb6385e commit 545291c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/main/java/com/thealgorithms/maths/Area.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ public static double surfaceAreaSphere(final double radius) {
4848
return 4 * Math.PI * radius * radius;
4949
}
5050

51+
/**
52+
* Calculate the surface area of a pyramid with a square base.
53+
*
54+
* @param sideLength side length of the square base
55+
* @param slantHeight slant height of the pyramid
56+
* @return surface area of the given pyramid
57+
*/
58+
public static double surfaceAreaPyramid(final double sideLength, final double slantHeight) {
59+
if (sideLength <= 0) {
60+
throw new IllegalArgumentException("Must be a positive sideLength");
61+
}
62+
if (slantHeight <= 0) {
63+
throw new IllegalArgumentException("Must be a positive slantHeight");
64+
}
65+
double baseArea = sideLength * sideLength;
66+
double lateralSurfaceArea = 2 * sideLength * slantHeight;
67+
return baseArea + lateralSurfaceArea;
68+
}
69+
5170
/**
5271
* Calculate the area of a rectangle.
5372
*

src/main/java/com/thealgorithms/sorts/BubbleSort.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* @author Varun Upadhyay (https://github.com/varunu28)
55
* @author Podshivalov Nikita (https://github.com/nikitap492)
6+
* @author Born-as-Harsha (https://github.com/Born-as-Harsha)
67
* @see SortAlgorithm
78
*/
89
class BubbleSort implements SortAlgorithm {

0 commit comments

Comments
 (0)