hacker's
var Point = function (x, y)
{
this.x = x;
this.y = y;
};
var PointPrototype = function ()
{
this.moveTo = function (x, y)
{
this.x = x;
this.y = y;
};
this.toString = function ()
{
return "(" + this.x + ", " + this.y + ")";
};
};
Point.prototype = new PointPrototype();
var ColoredPoint = function (x, y, color)
{
this.x = x;
this.y = y;
this.color = color;
};
var ColoredPointPrototype = function (x, y)
{
this.setColor = function (color)
{
this.color = color;
};
this.toString = function ()
{
return "(" + this.x + ", " + this.y + "; " + this.color + ")";
};
};
ColoredPoint.prototype = new ColoredPointPrototype();
ColoredPointPrototype.prototype = new PointPrototype();
hiyama's
var Point = function (x, y)
{
this.x = x;
this.y = y;
};
Point.prototype =
{
moveTo : function (x, y)
{
this.x = x;
this.y = y;
},
toString : function ()
{
return "(" + this.x + ", " + this.y + ")";
}
};
var ColoredPoint = function (x, y, color)
{
this.x = x;
this.y = y;
this.color = color;
};
ColoredPoint.prototype =
{
setColor : function (color)
{
this.color = color;
},
toString : function ()
{
return "(" + this.x + ", " + this.y + "; " + this.color + ")";
}
};
ColoredPoint.prototype.__proto__ = Point.prototype;