//***********************************************************
//*
//* File:           Robot.java
//* Author:         Srikant Krishna
//* Contact:        srikant@cs.columbia.edu
//* Update:         10/16/2002
//*
//* Description:    Robot class for Project 3.
//*
//***********************************************************


package Rectangles;

import java.io.*;
import java.awt.Color;

public class Robot implements Serializable {

    Vertex _position;
    Color _color;
    int _playerindex;
    int _id;
    static final String _CNULL_STRING = "[Null]";
    static final String _CERROR_STRING = "[Error]";

    public Robot(int __xpos, int __ypos) throws Exception {
       _position = new Vertex(__xpos, __ypos);
    }

    public int xpos() throws Exception {
        return _position.xpos();
    }

    public void setXpos(int __xpos) throws Exception {
        _position.setXpos(__xpos);
    }

    public int ypos() throws Exception {
        return _position.ypos();
    }

    public void setYpos(int __ypos) throws Exception {
        _position.setYpos(__ypos);
    }

    public int ID() throws Exception {
        return _id;
    }

    public void setID(int __id) throws Exception {
        _id = __id;
    }
    
    public Robot copy() throws Exception {
        Robot RET = new Robot(_position.xpos(), _position.ypos());
        RET._playerindex = _playerindex;
        RET._id = _id;
        if (_color != null) {
            RET._color = new Color(_color.getRGB());
        }
        return RET;
    }

    public String toString() {
        try {
            return "[" + _id + "]: " + ((_position == null) ? _CNULL_STRING : new String("["+_position._xpos+", "+_position._ypos+"]"));
        } catch (Exception EXC) {
            return _CERROR_STRING;
        }
    }

    public Color color() throws Exception {
        return _color;
    }

    public void setColor(Color __color) throws Exception {
        _color = __color;
    }

    public int playerIndex() throws Exception {
        return _playerindex;
    }

    public void setPlayerIndex(int __playerindex) throws Exception {
        _playerindex = __playerindex;
    }
}
