From 0291fbd96d5381c3cf6a2abfe4e4627729d6b30a Mon Sep 17 00:00:00 2001 From: "Adarsh.M" Date: Mon, 9 Feb 2026 20:20:11 +0530 Subject: [PATCH 1/6] fix:shape's dimension constraints added correctyl (issue id: #7260) --- .../java/com/thealgorithms/maths/Area.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 1eba6666dde3..8caa160c87e1 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -10,17 +10,17 @@ private Area() { /** * String of IllegalArgumentException for radius */ - private static final String POSITIVE_RADIUS = "Must be a positive radius"; + private static final String POSITIVE_RADIUS = "Radius must be greater than 0"; /** * String of IllegalArgumentException for height */ - private static final String POSITIVE_HEIGHT = "Must be a positive height"; + private static final String POSITIVE_HEIGHT = "Height must be greater than 0"; /** * String of IllegalArgumentException for base */ - private static final String POSITIVE_BASE = "Must be a positive base"; + private static final String POSITIVE_BASE = "Base must be greater than 0"; /** * Calculate the surface area of a cube. @@ -30,7 +30,7 @@ private Area() { */ public static double surfaceAreaCube(final double sideLength) { if (sideLength <= 0) { - throw new IllegalArgumentException("Must be a positive sideLength"); + throw new IllegalArgumentException("Side length must be greater than 0"); } return 6 * sideLength * sideLength; } @@ -57,10 +57,10 @@ public static double surfaceAreaSphere(final double radius) { */ public static double surfaceAreaPyramid(final double sideLength, final double slantHeight) { if (sideLength <= 0) { - throw new IllegalArgumentException("Must be a positive sideLength"); + throw new IllegalArgumentException(""); } if (slantHeight <= 0) { - throw new IllegalArgumentException("Must be a positive slantHeight"); + throw new IllegalArgumentException("slant height must be greater than 0"); } double baseArea = sideLength * sideLength; double lateralSurfaceArea = 2 * sideLength * slantHeight; @@ -76,10 +76,10 @@ public static double surfaceAreaPyramid(final double sideLength, final double sl */ public static double surfaceAreaRectangle(final double length, final double width) { if (length <= 0) { - throw new IllegalArgumentException("Must be a positive length"); + throw new IllegalArgumentException("Length must be greater than 0"); } if (width <= 0) { - throw new IllegalArgumentException("Must be a positive width"); + throw new IllegalArgumentException("Width must be greater than 0"); } return length * width; } @@ -109,7 +109,7 @@ public static double surfaceAreaCylinder(final double radius, final double heigh */ public static double surfaceAreaSquare(final double sideLength) { if (sideLength <= 0) { - throw new IllegalArgumentException("Must be a positive sideLength"); + throw new IllegalArgumentException("Side Length must be greater than 0"); } return sideLength * sideLength; } @@ -121,7 +121,7 @@ public static double surfaceAreaSquare(final double sideLength) { * @param height height of triangle * @return area of given triangle */ - public static double surfaceAreaTriangle(final double base, final double height) { + public static double surfaceAreaTriangle(final double baseLength, final double height) { if (base <= 0) { throw new IllegalArgumentException(POSITIVE_BASE); } From c720b02a6344d57bad8fd956611b2cc8b69f4de0 Mon Sep 17 00:00:00 2001 From: "Adarsh.M" Date: Mon, 9 Feb 2026 20:26:43 +0530 Subject: [PATCH 2/6] fix: base changed to baseLength for better understanding --- src/main/java/com/thealgorithms/maths/Area.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 8caa160c87e1..22dcc622728e 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -122,7 +122,7 @@ public static double surfaceAreaSquare(final double sideLength) { * @return area of given triangle */ public static double surfaceAreaTriangle(final double baseLength, final double height) { - if (base <= 0) { + if (baseLength<= 0) { throw new IllegalArgumentException(POSITIVE_BASE); } if (height <= 0) { From f4941f4ff18f255c3a5ed66ff18fdb203bdb01b2 Mon Sep 17 00:00:00 2001 From: "Adarsh.M" Date: Mon, 9 Feb 2026 20:30:02 +0530 Subject: [PATCH 3/6] fix: base changed to baseLength for better understanding --- src/main/java/com/thealgorithms/maths/Area.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 22dcc622728e..9ba4fba12dbb 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -128,7 +128,7 @@ public static double surfaceAreaTriangle(final double baseLength, final double h if (height <= 0) { throw new IllegalArgumentException(POSITIVE_HEIGHT); } - return base * height / 2; + return baseLength* height / 2; } /** @@ -138,8 +138,8 @@ public static double surfaceAreaTriangle(final double baseLength, final double h * @param height height of a parallelogram * @return area of given parallelogram */ - public static double surfaceAreaParallelogram(final double base, final double height) { - if (base <= 0) { + public static double surfaceAreaParallelogram(final double baseLength, final double height) { + if (baseLength <= 0) { throw new IllegalArgumentException(POSITIVE_BASE); } if (height <= 0) { @@ -156,17 +156,17 @@ public static double surfaceAreaParallelogram(final double base, final double he * @param height height of trapezium * @return area of given trapezium */ - public static double surfaceAreaTrapezium(final double base1, final double base2, final double height) { - if (base1 <= 0) { + public static double surfaceAreaTrapezium(final double baseLength1, final double baseLength2, final double height) { + if (baseLength1 <= 0) { throw new IllegalArgumentException(POSITIVE_BASE + 1); } - if (base2 <= 0) { + if (baseLength2 <= 0) { throw new IllegalArgumentException(POSITIVE_BASE + 2); } if (height <= 0) { throw new IllegalArgumentException(POSITIVE_HEIGHT); } - return (base1 + base2) * height / 2; + return (baseLength1 + baseLength2) * height / 2; } /** From 7f21bf277b502039bd8e35c35cd86afccf1101b2 Mon Sep 17 00:00:00 2001 From: "Adarsh.M" Date: Mon, 9 Feb 2026 20:33:13 +0530 Subject: [PATCH 4/6] base changed to baseLength for better understanding --- src/main/java/com/thealgorithms/maths/Area.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 9ba4fba12dbb..0a980deced57 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -145,7 +145,7 @@ public static double surfaceAreaParallelogram(final double baseLength, final dou if (height <= 0) { throw new IllegalArgumentException(POSITIVE_HEIGHT); } - return base * height; + return baseLength * height; } /** From 69073dea0df3a480344560d1276db31d40f192c6 Mon Sep 17 00:00:00 2001 From: "Adarsh.M" Date: Mon, 9 Feb 2026 20:35:33 +0530 Subject: [PATCH 5/6] fix:cleared some format issues --- src/main/java/com/thealgorithms/maths/Area.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index 0a980deced57..e3a46eb92568 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -128,7 +128,7 @@ public static double surfaceAreaTriangle(final double baseLength, final double h if (height <= 0) { throw new IllegalArgumentException(POSITIVE_HEIGHT); } - return baseLength* height / 2; + return baseLength * height / 2; } /** From a4620aaf1a3d61455cd4a29c3c8070c5c7abe13e Mon Sep 17 00:00:00 2001 From: "Adarsh.M" Date: Mon, 9 Feb 2026 20:40:19 +0530 Subject: [PATCH 6/6] fix:cleared some format issues --- src/main/java/com/thealgorithms/maths/Area.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/thealgorithms/maths/Area.java b/src/main/java/com/thealgorithms/maths/Area.java index e3a46eb92568..08807580cb03 100644 --- a/src/main/java/com/thealgorithms/maths/Area.java +++ b/src/main/java/com/thealgorithms/maths/Area.java @@ -122,7 +122,7 @@ public static double surfaceAreaSquare(final double sideLength) { * @return area of given triangle */ public static double surfaceAreaTriangle(final double baseLength, final double height) { - if (baseLength<= 0) { + if (baseLength <= 0) { throw new IllegalArgumentException(POSITIVE_BASE); } if (height <= 0) {