-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapeDraw.java
More file actions
24 lines (23 loc) · 774 Bytes
/
Copy pathShapeDraw.java
File metadata and controls
24 lines (23 loc) · 774 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
import java.util.Scanner;
public class ShapeDraw {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Sides of Shape");
int sides = in.nextInt();
Shape shape;
if(sides==3){
shape=new Triangle();
shape.setInfo("Triangle","YELLOW");
shape.displayInfo();
}else if(sides==4){
shape=new Square();
shape.setInfo("Square","RED");
shape.displayInfo();
}else{
shape= new Shape();
shape.setInfo("Simple Shape","GREEN");
shape.displayInfo();
}
shape.draw(); //it will show polymorphism behaviour based on users input
}
}