blob: d1b43d1b9690e53a5691fde9a30a3d043169d60f (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
|
/**
* Assignment 1, COMP268 Class: Triangle.java
*
* @description Represents a Triangle
* @author: mo khan Student ID: 3431709
* @date May 8, 2019
* @version 1.0
*/
package Q6;
public class Triangle {
public static double NULL = 0.0;
private double a, b, c;
/**
* Constructs a Triangle
*
* @param a the length of side A
* @param b the length of side B
* @param c the length of side C
*/
public Triangle(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
/** @return the length of side A */
public double getA() {
return this.a;
}
/** @return the length of side B */
public double getB() {
if (this.b == NULL) this.b = Math.sqrt(Math.pow(this.getC(), 2) - Math.pow(this.getA(), 2));
return this.b;
}
/** @return the length of side C */
public double getC() {
return this.c;
}
/**
* Determines if the triangle is a right angle triangle.
*
* @return boolean to indicate if the triangle is a right angle triangle
*/
public boolean isRightTriangle() {
return Math.pow(this.getA(), 2) + Math.pow(this.getB(), 2) == Math.pow(this.getC(), 2);
}
}
|