-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractShapes.java
More file actions
38 lines (36 loc) · 1.07 KB
/
Copy pathAbstractShapes.java
File metadata and controls
38 lines (36 loc) · 1.07 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
/*********************************************************************************************
* File :AbstractShapes.java
* Description :To get the number of sides of differet shapes
* Author :Shraya S Santhosh
* Version :1.0
* Date :27/10/2023
*********************************************************************************************/
package newproj;
public class AbstractShapes {
public static void main(String[]args) {
Rectangle rectangle=new Rectangle();
Triangle triangle=new Triangle();
Hexagon hexagon=new Hexagon();
rectangle.numberOfSides();
triangle.numberOfSides();
hexagon.numberOfSides();
}
}
abstract class Shapes{
abstract public void numberOfSides();
}
class Rectangle extends Shapes{
public void numberOfSides() {
System.out.println("No. of sides of rectange is 4");
}
}
class Triangle extends Shapes{
public void numberOfSides() {
System.out.println("No. of sides of triangle is 3");
}
}
class Hexagon extends Shapes{
public void numberOfSides() {
System.out.println("No. of sides of hexagon is 6");
}
}