Guest User

Untitled

a guest
Aug 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import Turtle.*;
  2. public class DrunkTurtle extends SimpleTurtle {
  3.  
  4.  
  5. public DrunkTurtle(){
  6. super();
  7.  
  8. }
  9.  
  10. public void moveForward(double d){
  11. double n=Math.random()*(2*d);
  12.  
  13. for(int i=0 ; i < 3 ; i++){
  14. int k = ((int)(Math.random()*61)-30);
  15. if(k%2 == 0)
  16. {
  17. if(k > 0)
  18. {
  19. this.turnLeft(k);
  20. }
  21. else
  22. {
  23. this.turnLeft(k);
  24. }
  25. }
  26. else
  27. {
  28. if(k > 0)
  29. {
  30. this.turnRight(k);
  31. }
  32. else
  33. {
  34. this.turnRight(k);
  35. }
  36. }
  37. super.moveForward(n/3);
  38. }
  39.  
  40. }
  41.  
  42. }
Add Comment
Please, Sign In to add comment