willieshi232

Untitled

Feb 22nd, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. public class Mouse implements Critter
  2. {
  3. private int count = 0;
  4. private int X;
  5. public char getChar()
  6. {
  7. return 'M';
  8. }
  9.  
  10. //Mouse critters move 1 West and 1 North in a zig zag fashion
  11. public int getMove(CritterInfo info)
  12. {
  13. int[] Array = {NORTH, WEST};
  14. if(count == 0)
  15. {
  16. X = Array[count];
  17. count++;
  18. }
  19. else if(count == 1)
  20. {
  21. X = Array[count];
  22. count = 0;
  23. }
  24. return X;
  25. }
  26. }
  27. import java.util.*;
  28. public class Frog implements Critter
  29. {
  30. private int count = 0;
  31. private int rNum;
  32.  
  33. public char getChar()
  34. {
  35. return 'F';
  36. }
  37.  
  38. //Randomly selects one of the four directions each time
  39. public int getMove(CritterInfo info)
  40. {
  41. int[] array = {NORTH, SOUTH, EAST, WEST};
  42. if(count == 0)
  43. {
  44. Random generator = new Random();
  45. rNum = generator.nextInt(4);
  46. count++;
  47. }
  48. else
  49. {
  50. count++;
  51. }
  52. while(count >= 3)
  53. {
  54. count = 0;
  55. }
  56. //System.out.print(array[rNum]);
  57. return array[rNum];
  58. }
  59. }
  60.  
  61. public class Wolf implements Critter
  62. {
  63. public char getChar()
  64. {
  65. return 'W';
  66. }
  67.  
  68. //stones don't move
  69. public int getMove(CritterInfo info)
  70. {
  71. return CENTER;
  72. }
  73. }
  74.  
  75. import java.util.*;
  76. public class Bird implements Critter
  77. {
  78. public char getChar()
  79. {
  80. return 'B';
  81. }
  82.  
  83. //Randomly selects one of the four directions each time
  84. public int getMove(CritterInfo info)
  85. {
  86. int[] array = {NORTH, SOUTH, EAST, WEST};
  87. Random generator = new Random();
  88. int X = generator.nextInt(4);
  89. return array[X];
  90. }
  91. public class Turtle implements Critter
  92. {
  93. private int count = 1;
  94. private int X;
  95. public char getChar()
  96. {
  97. return 'T';
  98. }
  99.  
  100. public int getMove(CritterInfo info)
  101. {
  102. if(count >= 20)
  103. {
  104. count = 0;
  105. }
  106. if(count < 5)
  107. {
  108. count++;
  109. return SOUTH;
  110. }
  111. else if(count >= 5 && count < 9)
  112. {
  113. count++;
  114. return WEST;
  115. }
  116. else if(count >= 9 && count < 14)
  117. {
  118. count++;
  119. return NORTH;
  120. }
  121. else
  122. {
  123. count++;
  124. return EAST;
  125. }
  126. }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment