Advertisement
Guest User

Untitled

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