Advertisement
OSRSMargins

Untitled

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