السلام عليكم
Write a java class named Triangle, as shown in the UML class diagram. The class contains the following:
• 3 private attributes named side1, side2 and side3, of type (int)
•A constructor that sets the 3 sides of the triangle to given values
•A method named isValid(), which returns true if the sum of any two sides is greater than the third side.
•A method named area() which returns the area of the triangle, using the following formula:
Write another class named TestTriangle with a main() method that will create a Triangle object, initialize the data of the triangle to values entered by the user, and computes the area if the input is valid. Otherwise, it displays that the input is not valid.
private int side1;
private int side2;
private int side3;
double s;
double area;
public Triangle(int a, int b , int c){
side1=a;
side2=b;
side3=c;
}
public boolean isValid(){
if (((side1 + side2) >side3) && ((side2 + side3) > side1) && ((side3 + side1) >side2))
return true;
return false;
}
public double area(){
s=(side1+side2+side3);
area = Math.sqrt(s * (s - side1) * (s-side3)*(s-side2));
return area;
}
}
class Triangle{import java.util.*;
public class TestTriangle{
static Scanner console=new Scanner(System.in);
public static void main(String[]args){
Triangle tr = new Triangle();
System.out.print("Enter the side1: ");
a = console.nextInt();
System.out.print("Enter the side2: ");
b = console.nextInt();
System.out.print("Enter the side3: ");
c = console.nextInt();
}
}
السؤال هو في الماين كيف انادي الكونستراكتر واخلي المستخدم يدخل القيم


