Advertisement
Guest User

Untitled

a guest
Nov 19th, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. class CompositeFigure {
  2.     public Figure[] figures;
  3.     public CompositeFigure(int size) {
  4.         figures = new Figure[size];
  5.     }
  6.     public void draw() {
  7.         for(Figure figure : figures) {
  8.             figure.draw();
  9.         }
  10.     }
  11. }
  12.  
  13. class Activity {
  14.     public static void main(String[] str) {
  15.         CompositeFigure figure = new CompositeFigure(2);
  16.         figure.figures[0] = new Circle();
  17.         figure.figures[1] = new Rectangle();
  18.         figure.draw();
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement