Good evening everyone! Im in a tight spot right now with my java programming assignment.. i will attach my code below but so far i'm having difficulties with the step (Create a method that returns a String indicating the type of triangle), I tried many ways to do this and i have no syntax errors but i just know its wrong because when i call the method in my TriangleTest class to return me the type of triangle it just doesnt work :/ Helppp please!!!
public class TriangleAnalyzer { private int side1; private int side2; private int side3; public TriangleAnalyzer(int sideLength1, int sideLength2, int sideLength3) { this.side1 = sideLength1; this.side2 = sideLength2; this.side3 = sideLength3; } public int getside1() { return side1; } public int getside2() { return side2; } public int getside3() { return side3; } public boolean isTriangle() { if (side1 + side2 > side3 || side2 + side3 > side1 || side1 + side3 > side2) { return true; } else { return false; } } public boolean isEquilateral(){ if (side1 == side2 && side1 == side3) { return true; } else { return false; } } public boolean isRight(){ //(If right angle) if side1 is hypotenuse int hypotenuse = (int) Math.sqrt (Math.pow(side2,2)+ Math.pow(side3,2)); if(hypotenuse == side1) { return true; } //if side2 is the hypotenuse hypotenuse = (int) Math.sqrt (Math.pow(side1,2)+ Math.pow(side3,2)); if(hypotenuse == side2) { return true; } //if side3 is hypotenuse hypotenuse = (int) Math.sqrt (Math.pow(side1,2)+ Math.pow(side2,2)); if(hypotenuse == side3) { return true; } else { return false; } } public boolean isIsosceles(){ if (side1 == side2 || side1 == side3 || side2 == side3) { return true; } else { return false; } } public boolean isObtuse(){ if (Math.sqrt(side1 + side2) < Math.sqrt (side3)) { return true; } else { return false; } } //create a method that returns a string indicating the type of triangle (equilateral, isosceles, right, obtuse). public void toString(boolean isEquilateral, boolean isObtuse, boolean isIsosceles, boolean isRight){ String equilateral = "equilateral"; if (isEquilateral) { System.out.println(equilateral); } String obtuse = "obtuse"; if (isObtuse) { System.out.println(obtuse); } String right = "right"; if (isRight) { System.out.println(right); } String isosceles = "isosceles"; if (isIsosceles) { System.out.println(isosceles); } else { System.out.println("not a triangle"); } } //and here below is my test class... import java.lang.String; import java.util.Scanner; import javax.swing.JOptionPane; /* This is a test class for tha Triangle Analyzer class. Make no changes to * this class other than adding the required statements in the TO DO section, * below. */ public class TriangleTester { public static void main(String[] args) { String input = JOptionPane.showInputDialog( "Enter the lengths of the 3 sides of the first triangle, " + "separated by spaces\n(or click Cancel to quit)"); while (input != null) { Scanner inputScan = new Scanner(input); int side1 = inputScan.nextInt(); // length of first side int side2 = inputScan.nextInt(); // length of second side int side3 = inputScan.nextInt(); // length of third side // TO DO: // 1. Create a Triangle Analyzer object using side1, side2, // and side3 TriangleAnalyzer triangle = new TriangleAnalyzer(side1, side2, side3); // 2. Call the accessor mathods to get the lengths of the sides // and print them System.out.println("The length of side 1 is :" + triangle.getside1()); System.out.println("The length of side 2 is :" + triangle.getside2()); System.out.println("The length of side 3 is :" + triangle.getside3()); // 3. Call the method that returns the type of triangle (or an // appropriate message if the sides do not form a triangle) // and print it // System.out.println("The type of triangle is " + triangle.); //stuck on this part cant seem to figure out how to call the method that returns the strings.. // 4. If the side lengths do form a triangle, call the method that // computes and returns the area and print it, rounded to 2 // decimal places input = JOptionPane.showInputDialog( "Enter the lengths of the 3 sides of the next triangle, " + "separated by spaces\n(or click Cancel to quit)"); } } }