-
Notifications
You must be signed in to change notification settings - Fork 143
/
TestShapes.java
42 lines (33 loc) · 1.02 KB
/
TestShapes.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
public class TestShapes {
public static void main(String[] args) {
Sphere sphere = new Sphere();
Circle circle = new Circle();
Shapes shapes = new Sphere();
Shapes originalShapes = new Shapes();
System.out.println("Area of Sphere is "+sphere.getArea(2.1));
System.out.println("Area of Circle is "+circle.getArea(2.1));
System.out.println(circle.getAStatement());
System.out.println("Area of relevant Sphere is "+shapes.getArea(2.1));
System.out.println("Area of relevant Sphere is "+originalShapes.getArea(2.1));
}
}
class Shapes{
double getArea(double radius){
return 0.0;
}
public String getAStatement(){
return "I am a shape";
}
}
class Sphere extends Shapes{
@Override
double getArea(double radius){
return 4 * Math.PI * radius * radius;
}
}
class Circle extends Shapes{
@Override
double getArea(double radius){
return Math.PI * radius * radius;
}
}