- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab_Task.java
More file actions
Latest commit
36 lines (35 loc) · 890 Bytes
/
Copy pathlab_Task.java
File metadata and controls
36 lines (35 loc) · 890 Bytes
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
abstractclassShape {
abstractdoublearea();
voiddisplay() {
System.out.println("This is a shape");
}
}
classCircleextendsShape {
doubleradius;
Circle(doubleradius) {
this.radius = radius;
}
doublearea() {
returnMath.PI * radius * radius;
}
}
classRectangleextendsShape {
doublelength, width;
Rectangle(doublelength, doublewidth) {
this.length = length;
this.width = width;
}
doublearea() {
returnlength * width;
}
}
publicclasslab_Task{
publicstaticvoidmain(String[] args) {
Shapes1 = newCircle(5);
Shapes2 = newRectangle(4, 6);
s1.display();
System.out.println("Circle Area: " + s1.area());
s2.display();
System.out.println("Rectangle Area: " + s2.area());
}
}