-
Notifications
You must be signed in to change notification settings - Fork 1
/
Triangle.java
54 lines (44 loc) · 1019 Bytes
/
Triangle.java
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
53
54
class Triangle{
private int x;
private int y;
private int z;
Triangle(){
x =0;
y =0;
z = 0;
}
Triangle(int x,int y,int z){
this.x=x;
this.y=y;
this.z=z;
}
void showInfo(){
System.out.println("x: "+x);
System.out.println("y: "+y);
System.out.println("z: "+z);
}
void testTriangle(){
if(x==y&&y==z&&x==z){
System.out.println("the triangle is equilateral");
}
else if((x==y&&x!=z)||(x==z&&x!=y)||(y==z&&y!=x)){
System.out.println("the triangle is isosceles");
}
else{
System.out.println("the triangle is scalene");
}
}
public static void main(String args[]){
Triangle obj1 = new Triangle();
obj1.showInfo();
Triangle obj2 = new Triangle(23,23,23);
obj2.showInfo();
obj2.testTriangle();
Triangle obj3 = new Triangle(29,43,23);
obj3.showInfo();
obj3.testTriangle();
Triangle obj4 = new Triangle(23,43,23);
obj4.showInfo();
obj4.testTriangle();
}
}