@@ -10,17 +10,17 @@ private Area() {
1010 /**
1111 * String of IllegalArgumentException for radius
1212 */
13- private static final String POSITIVE_RADIUS = "Must be a positive radius " ;
13+ private static final String POSITIVE_RADIUS = "Radius must be greater than 0 " ;
1414
1515 /**
1616 * String of IllegalArgumentException for height
1717 */
18- private static final String POSITIVE_HEIGHT = "Must be a positive height " ;
18+ private static final String POSITIVE_HEIGHT = "Height must be greater than 0 " ;
1919
2020 /**
2121 * String of IllegalArgumentException for base
2222 */
23- private static final String POSITIVE_BASE = "Must be a positive base " ;
23+ private static final String POSITIVE_BASE = "Base must be greater than 0 " ;
2424
2525 /**
2626 * Calculate the surface area of a cube.
@@ -30,7 +30,7 @@ private Area() {
3030 */
3131 public static double surfaceAreaCube (final double sideLength ) {
3232 if (sideLength <= 0 ) {
33- throw new IllegalArgumentException ("Must be a positive sideLength " );
33+ throw new IllegalArgumentException ("Side length must be greater than 0 " );
3434 }
3535 return 6 * sideLength * sideLength ;
3636 }
@@ -57,10 +57,10 @@ public static double surfaceAreaSphere(final double radius) {
5757 */
5858 public static double surfaceAreaPyramid (final double sideLength , final double slantHeight ) {
5959 if (sideLength <= 0 ) {
60- throw new IllegalArgumentException ("Must be a positive sideLength " );
60+ throw new IllegalArgumentException ("" );
6161 }
6262 if (slantHeight <= 0 ) {
63- throw new IllegalArgumentException ("Must be a positive slantHeight " );
63+ throw new IllegalArgumentException ("slant height must be greater than 0 " );
6464 }
6565 double baseArea = sideLength * sideLength ;
6666 double lateralSurfaceArea = 2 * sideLength * slantHeight ;
@@ -76,10 +76,10 @@ public static double surfaceAreaPyramid(final double sideLength, final double sl
7676 */
7777 public static double surfaceAreaRectangle (final double length , final double width ) {
7878 if (length <= 0 ) {
79- throw new IllegalArgumentException ("Must be a positive length " );
79+ throw new IllegalArgumentException ("Length must be greater than 0 " );
8080 }
8181 if (width <= 0 ) {
82- throw new IllegalArgumentException ("Must be a positive width " );
82+ throw new IllegalArgumentException ("Width must be greater than 0 " );
8383 }
8484 return length * width ;
8585 }
@@ -109,7 +109,7 @@ public static double surfaceAreaCylinder(final double radius, final double heigh
109109 */
110110 public static double surfaceAreaSquare (final double sideLength ) {
111111 if (sideLength <= 0 ) {
112- throw new IllegalArgumentException ("Must be a positive sideLength " );
112+ throw new IllegalArgumentException ("Side Length must be greater than 0 " );
113113 }
114114 return sideLength * sideLength ;
115115 }
@@ -121,14 +121,14 @@ public static double surfaceAreaSquare(final double sideLength) {
121121 * @param height height of triangle
122122 * @return area of given triangle
123123 */
124- public static double surfaceAreaTriangle (final double base , final double height ) {
125- if (base <= 0 ) {
124+ public static double surfaceAreaTriangle (final double baseLength , final double height ) {
125+ if (baseLength <= 0 ) {
126126 throw new IllegalArgumentException (POSITIVE_BASE );
127127 }
128128 if (height <= 0 ) {
129129 throw new IllegalArgumentException (POSITIVE_HEIGHT );
130130 }
131- return base * height / 2 ;
131+ return baseLength * height / 2 ;
132132 }
133133
134134 /**
@@ -138,14 +138,14 @@ public static double surfaceAreaTriangle(final double base, final double height)
138138 * @param height height of a parallelogram
139139 * @return area of given parallelogram
140140 */
141- public static double surfaceAreaParallelogram (final double base , final double height ) {
142- if (base <= 0 ) {
141+ public static double surfaceAreaParallelogram (final double baseLength , final double height ) {
142+ if (baseLength <= 0 ) {
143143 throw new IllegalArgumentException (POSITIVE_BASE );
144144 }
145145 if (height <= 0 ) {
146146 throw new IllegalArgumentException (POSITIVE_HEIGHT );
147147 }
148- return base * height ;
148+ return baseLength * height ;
149149 }
150150
151151 /**
@@ -156,17 +156,17 @@ public static double surfaceAreaParallelogram(final double base, final double he
156156 * @param height height of trapezium
157157 * @return area of given trapezium
158158 */
159- public static double surfaceAreaTrapezium (final double base1 , final double base2 , final double height ) {
160- if (base1 <= 0 ) {
159+ public static double surfaceAreaTrapezium (final double baseLength1 , final double baseLength2 , final double height ) {
160+ if (baseLength1 <= 0 ) {
161161 throw new IllegalArgumentException (POSITIVE_BASE + 1 );
162162 }
163- if (base2 <= 0 ) {
163+ if (baseLength2 <= 0 ) {
164164 throw new IllegalArgumentException (POSITIVE_BASE + 2 );
165165 }
166166 if (height <= 0 ) {
167167 throw new IllegalArgumentException (POSITIVE_HEIGHT );
168168 }
169- return (base1 + base2 ) * height / 2 ;
169+ return (baseLength1 + baseLength2 ) * height / 2 ;
170170 }
171171
172172 /**
0 commit comments