diff options
| author | mokha <mokha@cisco.com> | 2019-05-05 19:25:48 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-05 19:25:48 -0600 |
| commit | 46e409f3ca33ec3c7546d0589301c2a4f967c10a (patch) | |
| tree | 55ed5a3297517719af1856f8fd0fa848dd4b94b5 /src/main/java/ca/mokhan/assignment1/Triangle.java | |
| parent | c66b9591c81f93e3966050cc7c88981018e9b542 (diff) | |
collapse assignment1 dir
Diffstat (limited to 'src/main/java/ca/mokhan/assignment1/Triangle.java')
| -rw-r--r-- | src/main/java/ca/mokhan/assignment1/Triangle.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/ca/mokhan/assignment1/Triangle.java b/src/main/java/ca/mokhan/assignment1/Triangle.java new file mode 100644 index 0000000..cf45ec2 --- /dev/null +++ b/src/main/java/ca/mokhan/assignment1/Triangle.java @@ -0,0 +1,29 @@ +package ca.mokhan.assignment1; + +public class Triangle { + public static double NULL = 0.0; + private double a, b, c; + + public Triangle(double a, double b, double c) { + this.a = a; + this.b = b; + this.c = c; + } + + public double getA() { + return this.a; + } + + public double getB() { + if (this.b == NULL) this.b = Math.sqrt(Math.pow(this.getC(), 2) - Math.pow(this.getA(), 2)); + return this.b; + } + + public double getC() { + return this.c; + } + + public boolean isRightTriangle() { + return Math.pow(this.getA(), 2) + Math.pow(this.getB(), 2) == Math.pow(this.getC(), 2); + } +} |
