Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class drunkTutle here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class drunkTutle extends Turtle
  9. {
  10. public void moveForward(double size)
  11. {
  12. super.moveForward(Math.random()*size);
  13. double rand = Math.random();
  14. if(rand<=0.3)
  15. turnLeft(90);
  16.  
  17. rand = Math.random();
  18. if(rand<=0.2)
  19. {
  20. super.moveForward(Math.random()*(-size));
  21. }
  22. else
  23. {
  24. super.moveForward(Math.random()*(size));
  25. }
  26. }
  27.  
  28. public void turnL(int y)
  29. {
  30. y = (int)(y*2*Math.random());
  31. turnLeft(y);
  32. }
  33.  
  34. public void turnR(int y)
  35. {
  36. y = (int)(y*2*Math.random());
  37. turnRight(y);
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement