-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.java
More file actions
82 lines (82 loc) · 1.55 KB
/
point.java
File metadata and controls
82 lines (82 loc) · 1.55 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class point{
void show(){
System.out.println("This is the Point Base class");
}
}
class shape extends point{
void display(){
System.out.println("Different shapes can be developed with different number of points");
}
}
class rectangle extends shape{
int l,b;
void getdata(int x,int y){
l=x;b=y;
}
void area(){
System.out.println("Length:"+l);
System.out.println("Breadth:"+b);
System.out.println("Area:"+(l*b));
}
}
class square extends shape{
int a;
void gdata(int x){
a=x;
}
void area(){
System.out.println("Side:"+a);
System.out.println("Area:"+(a*a));
}
}
class circle extends shape{
int r;
void get(int x){
r=x;
}
void area(){
System.out.println("Radius:"+r);
System.out.println("Area:"+(3.14*r*r));
}
}
class triangle extends shape{
int b,h;
void tdata(int x,int y){
b=x;h=y;
}
void area(){
System.out.println("Base:"+b);
System.out.println("Height:"+h);
System.out.println("Area:"+(0.5*b*h));
}
}
class ShapeTest{
public static void main(String args[]){
rectangle r = new rectangle();
square s = new square();
circle c = new circle();
triangle t = new triangle();
r.show();
s.display();
System.out.println("");
System.out.println("Rectangle:");
System.out.println();
r.getdata(12,6);
r.area();
System.out.println("");
System.out.println("Square:");
System.out.println();
s.gdata(7);
s.area();
System.out.println("");
System.out.println("Circle:");
System.out.println();
c.get(5);
c.area();
System.out.println("");
System.out.println("Triangle:");
System.out.println();
t.tdata(4,7);
t.area();
}
}