Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 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.                 }
  16.                 else{
  17.                     xPos = 5;
  18.                     yPos = -5;
  19.                     movePen(smallSquare, xPos, yPos);
  20.                     turnDirection(direction);
  21.                    
  22.                 }
  23.             }
  24.             liftPen();
  25.         }
  26.    
  27.     public static void liftPen(){
  28.         System.out.println("Lifting the pen from the paper");
  29.     }
  30.    
  31.     public static void lowerPen(){
  32.          System.out.println("Lowering the pen to draw on the paper");
  33.     }
  34.    
  35.     public static void movePen(int lenght, int xPos, int yPos){
  36.         System.out.println("Pen's starting position is:  " + "x=" + xPos + " y=" + yPos + " Moving pen by " + lenght + "cm");
  37.     }
  38.    
  39.     public static void turnDirection(int degree){
  40.         System.out.println("turning pen by " + degree +"°");
  41.     }
  42.    
  43.    
  44.     public static void main(String args[]) {
  45.        
  46.      
  47.       drawTwosquares();
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement