diff options
Diffstat (limited to 'src/Q6/Triangle.java')
| -rw-r--r-- | src/Q6/Triangle.java | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/Q6/Triangle.java b/src/Q6/Triangle.java deleted file mode 100644 index 3e641ce..0000000 --- a/src/Q6/Triangle.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * 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); - } - - /** @return a string with the length of each side */ - @Override - public String toString() { - return String.format("A: %f, B: %f, C: %f", this.getA(), this.getB(), this.getC()); - } - - public static void main(String[] args) { - System.out.println(new Triangle(48, Triangle.NULL, 80).toString()); - System.out.println(new Triangle(84, Triangle.NULL, 91).toString()); - - System.out.println(new Triangle(45, 55, 75).isRightTriangle()); - System.out.println(new Triangle(28, 45, 53).isRightTriangle()); - } -} |
