Solution Review: Calculating the Area
In this review, solution of the challenge 'Calculating the Area' from the previous lesson is provided.
We'll cover the following...
Solution: Did you find the ‘right’ area? #
Press + to interact
class rightAngleTriangle {//Define the member variables, constructor and// relevant area methodprivate double length;private double height;public rightAngleTriangle(int l, int h) {length = l;height = h;}public double area() {return (length * height / 2.0);}}class challenge_one {public static double test(rightAngleTriangle rt) {return rt.area();}public static void main( String args[] ) {rightAngleTriangle one= new rightAngleTriangle(3,5);System.out.println("Area of right Angle traingle:" + test(one));}}
Understanding the code
...