Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Mouse implements Critter
- {
- private int count = 0;
- private int X;
- public char getChar()
- {
- return 'M';
- }
- //Mouse critters move 1 West and 1 North in a zig zag fashion
- public int getMove(CritterInfo info)
- {
- int[] Array = {NORTH, WEST};
- if(count == 0)
- {
- X = Array[count];
- count++;
- }
- else if(count == 1)
- {
- X = Array[count];
- count = 0;
- }
- return X;
- }
- }
- import java.util.*;
- public class Frog implements Critter
- {
- private int count = 0;
- private int rNum;
- public char getChar()
- {
- return 'F';
- }
- //Randomly selects one of the four directions each time
- public int getMove(CritterInfo info)
- {
- int[] array = {NORTH, SOUTH, EAST, WEST};
- if(count == 0)
- {
- Random generator = new Random();
- rNum = generator.nextInt(4);
- count++;
- }
- else
- {
- count++;
- }
- while(count >= 3)
- {
- count = 0;
- }
- //System.out.print(array[rNum]);
- return array[rNum];
- }
- }
- public class Wolf implements Critter
- {
- public char getChar()
- {
- return 'W';
- }
- //stones don't move
- public int getMove(CritterInfo info)
- {
- return CENTER;
- }
- }
- import java.util.*;
- public class Bird implements Critter
- {
- public char getChar()
- {
- return 'B';
- }
- //Randomly selects one of the four directions each time
- public int getMove(CritterInfo info)
- {
- int[] array = {NORTH, SOUTH, EAST, WEST};
- Random generator = new Random();
- int X = generator.nextInt(4);
- return array[X];
- }
- public class Turtle implements Critter
- {
- private int count = 1;
- private int X;
- public char getChar()
- {
- return 'T';
- }
- public int getMove(CritterInfo info)
- {
- if(count >= 20)
- {
- count = 0;
- }
- if(count < 5)
- {
- count++;
- return SOUTH;
- }
- else if(count >= 5 && count < 9)
- {
- count++;
- return WEST;
- }
- else if(count >= 9 && count < 14)
- {
- count++;
- return NORTH;
- }
- else
- {
- count++;
- return EAST;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment