-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShapes.java
More file actions
36 lines (29 loc) · 735 Bytes
/
Shapes.java
File metadata and controls
36 lines (29 loc) · 735 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
package polymorphism;
import polymorphism.shape.*;
/**
* RUN:
* javac polymorphism/Shapes.java && java polymorphism.Shapes
* OUTPUT:
* Triangle.draw()
* Triangle.draw()
* Square.draw()
* Triangle.draw()
* Square.draw()
* Triangle.draw()
* Square.draw()
* Triangle.draw()
* Circle.draw()
*/
public class Shapes {
private static RandomShapeGenerator gen = new RandomShapeGenerator();
public static void main(String[] args)
{
Shape[] s = new Shape[9];
for (int i = 0; i < s.length; i++) {
s[i] = gen.next();
}
for (Shape shp : s) {
shp.draw();
}
}
}