/** This class acts as an intermediary between the Rover and the Prodigy, and visa-versa. The Prodigy rarely interacts with a Rover on its own; it has these records to track the pose, status, and role of each Rover. */ public class Record { private Rover rover; // The rover we're tracking private Pose pose; // The rover's pose private int targetID; // The ID of our 'mate' private static int port = 6665; /** Creates a rover and a pose object, then starts our Rover thread. */ public Record (Prodigy prodigy, int id) { rover = new Rover(prodigy, id, port); port++; pose = new Pose(0,0,(short)0); new Thread(rover).start(); } /** returns the role of the target rover. */ public int getRole () { return rover.getRole(); } /** sets the role of the target rover. */ public void setRole (int newRole) { rover.setRole(newRole); } /** Sets the role of the target rover to OBSERVER */ public void setObserver (int targetID) { setRole(Roles.OBSERVER); this.targetID = targetID; } /** gets the target ID, if this is an Observer. */ public int getTargetID () { return targetID; } /** Returns a pointer to the target Rover. */ public Rover getRover () { return rover; } /** Returns the Pose as it is now. */ public synchronized Pose getPose () { return pose; } /** Changes the current pose to the parameter. Used for every update.*/ public void changePose (Pose newPose) { pose = newPose; } /** Returns a string that represents this record, rover, & pose. */ public String toString() { return "ID: "+rover.getID()+"\t"+pose; } }