Advertisement
Guest User

Untitled

a guest
Mar 16th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. //(function () {
  2. var Shape = (function () {
  3.  
  4. function Shape(x, y, color) {
  5. this._x = x;
  6. this._y = y;
  7. this._color = color;
  8. }
  9. Shape.prototype.toString = function(){
  10. return "x= " + this._x, + ", y= " + this._y + "color: " + this._color;
  11. }
  12. return Shape;
  13. }());
  14.  
  15. var Circle = (function () {
  16.  
  17. function Circle(x, y, color, r) {
  18. Shape.call(this, x, y, color);
  19. this._r = r;
  20. }
  21. Circle.prototype = Object.create(Shape.prototype);
  22. Circle.prototype.constructor = Circle;
  23. // Circle.prototype = new Shape();
  24. return Circle;
  25.  
  26. Circle.prototype.toString = function () {
  27. return Shape.prototype.toString.call(this) + ", r = " + this._r;
  28. }
  29. }());
  30.  
  31. var c = new Circle(1, 2, 5, 7);
  32. console.log(c.toString());
  33. //}());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement