Advertisement
OSRSMargins

Untitled

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