// Squirrel.java // Description: Makes the squirrel run away! // Author: // Date: package myPackage; public class Squirrel implements Interface { // Current location of squirrel private int currentRow; private int currentCol; private char board[][]; // Information about closest terrier private int closestRow; private int closestCol; private double closestDistance; // Create a squirrel public Squirrel(int row, int Col, char board[][]) { this.currentRow = row; this.currentCol = Col; this.board = board; } // Getters for squirrel public int getCurrentRow() { return currentRow; } public int getCurrentCol() { return currentCol; } public int getClosestRow() { return closestRow; } public int getClosestCol() { return closestCol; } public double getClosestDist() { return closestDistance; } // Setters for squirrel public void setCurrentRow(int row) { this.currentRow = row; } public void setCurrentCol(int col) { this.currentCol = col; } // Move the squirrel public eMove move() { // Call method to find closest terrier // --- student code here --- // Call method to figure out move in opposite direction eMove e = eMove.LEFT; // --- student code here --- // Call method to avoid going off the board // --- student code here --- // Return move return e; } // Method to find closest terrier // Method to figure out move in opposite direction // Method to avoid going off the board // Compute euclidean distance private double computeDistance(int row0, int row1, int col0, int col1) { double rowDiff = Math.pow(row1 - row0, 2); double colDiff = Math.pow(col1 - col0, 2); return Math.sqrt(rowDiff + colDiff); } }