Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. public class MyClass {
  2.    
  3.    
  4.     public static void drawTwosquares(){
  5.         int bigSquare = 20;
  6.         int smallSquare = 10;
  7.         int direction = 90;
  8.         int xPos = 0;
  9.         int yPos = 0;
  10.             lowerPen();
  11.             for(int i = 0; i < 8; i = i +1){
  12.                 if (i < 4){
  13.                    movePen(bigSquare, xPos, yPos);
  14.                    turnDirection(direction);
  15.                    System.out.println(i);
  16.                    if (i == 3 ){liftPen();
  17.                        
  18.                    }
  19.                 }
  20.                 else{
  21.                     if (i == 4){
  22.                         lowerPen();
  23.                     }
  24.                     xPos = 5;
  25.                     yPos = -5;
  26.                     movePen(smallSquare, xPos, yPos);
  27.                     turnDirection(direction);
  28.                    
  29.                 }
  30.             }
  31.             liftPen();
  32.         }
  33.    
  34.     public static void liftPen(){
  35.         System.out.println("Lifting the pen from the paper");
  36.     }
  37.    
  38.     public static void lowerPen(){
  39.          System.out.println("Lowering the pen to draw on the paper");
  40.     }
  41.    
  42.     public static void movePen(int lenght, int xPos, int yPos){
  43.         System.out.println("Pen's starting position is:  " + "x=" + xPos + " y=" + yPos + " Moving pen by " + lenght + "cm");
  44.     }
  45.    
  46.     public static void turnDirection(int degree){
  47.         System.out.println("turning pen by " + degree +"°");
  48.     }
  49.    
  50.    
  51.     public static void main(String args[]) {
  52.        
  53.      
  54.       drawTwosquares();
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement