Advertisement
OSRSMargins

Untitled

Sep 28th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. public class FractalTest {
  2.  
  3.     private List<Fractal> fractals = new ArrayList<>();
  4.     private int count = 0;
  5.  
  6.     public final void run() {
  7.         // Lambda Runnable
  8.         for (int i = 0; i < 3; i++) {
  9.             Runnable task = () -> { {
  10.                 try {
  11.                     int left = 1;
  12.                     int bottom = 2;
  13.                     int right = 3;
  14.                     Fractal fractal = new Fractal(left, bottom, right);
  15.                     fractals.add(fractal);
  16.                 } finally {
  17.                     tick();
  18.                 }
  19.             }};
  20.             // start the thread
  21.             new Thread(task).start();
  22.         }
  23.     }
  24.  
  25.     public void tick() {
  26.         count++;
  27.         if (count == 3) drawFractals();
  28.     }
  29.  
  30.     private void drawFractals() {
  31.         fractals.forEach((fractal -> fractal.draw(canvas)));
  32.     }
  33.  
  34.  
  35. }
  36.  
  37. class Fractal {
  38.  
  39.     private final int left;
  40.     private final int bottom;
  41.     private final int right;
  42.  
  43.  
  44.     public Fractal(int left, int bottom, int right) {
  45.         this.left = left;
  46.         this.bottom = bottom;
  47.         this.right = right;
  48.     }
  49.  
  50.     public int getLeft() {
  51.         return left;
  52.     }
  53.  
  54.     public int getBottom() {
  55.         return bottom;
  56.     }
  57.  
  58.     public int getRight() {
  59.         return right;
  60.     }
  61.  
  62.     public void draw(Canvas canvas) {
  63.         //Method to draw the fractal on the canvas
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement