-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathArea_Calc.java
More file actions
41 lines (36 loc) · 1.01 KB
/
Area_Calc.java
File metadata and controls
41 lines (36 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package geometry;
/**
* Class: Area_Calc
* Description: Part of the 'geometry' package.
* Contains methods to calculate the area of different shapes.
* Author: Amey Thakur
* Reference: https://github.com/Amey-Thakur/OOPM-JAVA-LAB
*/
public class Area_Calc {
/**
* Calculate area of a rectangle.
* @param length Length of the rectangle
* @param breadth Breadth of the rectangle
* @return Area of the rectangle
*/
public int areaRect(int length, int breadth) {
return length * breadth;
}
/**
* Calculate area of a square.
* @param side Side length of the square
* @return Area of the square
*/
public int areaSquare(int side) {
return side * side;
}
/**
* Calculate area of a triangle.
* @param base Base length of the triangle
* @param height Height of the triangle
* @return Area of the triangle
*/
public float areaTriangle(int base, int height) {
return 0.5f * base * height;
}
}