Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.65 KB | None | 0 0
  1.  
  2. import gdi.machines.Controller;
  3.  
  4. public class ControlPanel {
  5.  
  6.     private static int xCounter = 3;
  7.     private static int yCounter = 3;
  8.     private static int anfangBewegungX = 2;
  9.     private static int endBewegungX = 0;
  10.     private static int anfangBewegungY = 2;
  11.     private static int endBewegungY = 0;
  12.  
  13.     public static boolean isValid(Controller c, int x, int y) {
  14.         if (x <= c.getMaxX() && x >= 0 && y <= c.getMaxY() && y >= 0) {
  15.             return true;
  16.         } else {
  17.             return false;
  18.         }
  19.     }
  20.  
  21.     public static boolean isValid(int width, int height, int x, int y) {
  22.         if (x < width && x >= 0 && y < height && y >= 0) {
  23.             return true;
  24.         } else {
  25.             return false;
  26.         }
  27.     }
  28.  
  29.     public static void moveTo(Controller c, int x, int y) {
  30.         if (ControlPanel.isValid(c, x, y)) {
  31.             if (c.getX() < x) {
  32.                 xCounter = 0;
  33.                 for (int i = c.getX(); i < x; i++) {
  34.                     c.moveE();
  35.                     xCounter++;
  36.                 }
  37.             }
  38.             if (c.getX() > x) {
  39.                 xCounter = 0;
  40.                 for (int i = c.getX(); i > x; i--) {
  41.                     c.moveW();
  42.                     xCounter++;
  43.                 }
  44.             }
  45.             if (c.getX() == x) {
  46.  
  47.             }
  48.             if (c.getY() == y) {
  49.  
  50.             }
  51.             if (c.getY() <= y) {
  52.                 yCounter = 0;
  53.                 for (int i = c.getY(); i < y; i++) {
  54.                     c.moveS();
  55.                     yCounter++;
  56.                 }
  57.             }
  58.             if (c.getY() > y) {
  59.                 yCounter = 0;
  60.                 for (int i = c.getY(); i > y; i--) {
  61.                     yCounter++;
  62.                     c.moveN();
  63.                 }
  64.             }
  65.         }
  66.     }
  67.  
  68.     public static void millSpirla(Controller c) {
  69.         int n = 0;
  70.         for (boolean i = true; i == true; n = n + 2) {
  71.             c.lowerTool();
  72.  
  73.             if (((c.getY()) < (int) (c.getMaxY() / 2) + 1)) {
  74.                 anfangBewegungX = c.getX();
  75.                 ControlPanel.moveTo(c, c.getMaxX() - n, n);
  76.                 endBewegungX = c.getX();
  77.             } else {
  78.                 break;
  79.             }
  80.             if (((c.getX() > ((int) (c.getMaxX() / 2) - 1)))) {
  81.                 anfangBewegungY = c.getY();
  82.                 ControlPanel.moveTo(c, c.getMaxX() - n, c.getMaxY() - n);
  83.                 endBewegungY = c.getY();
  84.             } else {
  85.                 break;
  86.             }
  87.             if ((endBewegungY - anfangBewegungY != 1) && ((c.getY()) > ((int) c.getMaxY() / 2))) {
  88.                 anfangBewegungX = c.getX();
  89.                 ControlPanel.moveTo(c, n, c.getMaxY() - n);
  90.                 endBewegungX = c.getX();
  91.             } else {
  92.                 break;
  93.             }
  94.             if ((endBewegungX - anfangBewegungX != 1) && ((c.getX()) < ((int) c.getMaxX() / 2))) {
  95.                 anfangBewegungY = c.getY();
  96.                 ControlPanel.moveTo(c, n, n + 2);
  97.                 endBewegungY = c.getY();
  98.             } else {
  99.                 break;
  100.             }
  101.             c.raiseTool();
  102.  
  103.         }
  104.     }
  105.  
  106.     public static void cutHorizontal(Controller c, int y) {
  107.         ControlPanel.moveTo(c, 0, y);
  108.         c.lowerTool();
  109.         ControlPanel.moveTo(c, 20, c.getY());
  110.         c.raiseTool();
  111.     }
  112.  
  113.     public static void main(String[] args) {
  114.         Controller a = new Controller(1, 25, 21);
  115.         ControlPanel.millSpirla(a);
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement