import java.awt.point;
import java.io.bytearrayinputstream;
import java.io.bytearrayoutputstream;
import java.io.ioexception;
import java.io.objectinputstream;
import java.io.objectoutputstream;
import java.io.serializable;
import com.sun.corba.se.impl.io.optionaldataexception;
/**
* 正方形
*
* @author 88250
* @version 1.0.0, 2007-8-26
*/
public class square implements cloneable, serializable
{
private point location = new point(0, 0);
private float sidelength = 1f;
@override
public object clone()
{
square tmp = null;
try
{
tmp = (square) super.clone();
}
catch (clonenotsupportedexception cnse)
{
cnse.printstacktrace();
}
finally
{
return tmp;
}
}
/**
* 深克隆方法
* @return
*/
public object deepclone()
throws ioexception, optionaldataexception, classnotfoundexception
{
// 首先将对象写到流里
bytearrayoutputstream bo = new bytearrayoutputstream();
objectoutputstream oo = new objectoutputstream(bo);
oo.writeobject(this);
// 然后将对象从流里读出来
bytearrayinputstream bi = new bytearrayinputstream(bo.tobytearray());
objectinputstream oi = new objectinputstream(bi);
return (oi.readobject());
}
/**
* @return the location
*/
public point getlocation()
{
return location;
}
/**
* @param location the location to set
*/
public void setlocation(point location)
{
this.location = location;
}
/**
* @return the sidelength
*/
public float getsidelength()
{
return sidelength;
}
/**
* @param sidelength the sidelength to set
*/
public void setsidelength(float sidelength)
{
this.sidelength = sidelength;
}
}
|