// INHERITANCE: Pattern1

console.log("INHERITANCE pattern1");
var Parent = function(name, age) {
	this.name = name;
	this.age = age;
	console.log("Parent constructor");
};

Parent.prototype = {
	getName: function() {
		return this.name;
	},
	getAge : function() {
		return this.age;
	},
	showData: function() {
		console.log("Parent: showData");
	}

};

var Child = function() {
	Parent.apply(this, arguments);
};

Child.prototype = new Parent();

Child.prototype = {
	showData: function() {
		console.log("Child: showData");
	},
	getName: function() {
		return this.name;
	}
};

console.log("\nCreate john");
var john = new Parent("john", 27);
john.showData();

console.log("\nCreate daniel");
var daniel = new Child("daniel", 18);
console.log(daniel.name);
daniel.showData();


// INHERITANCE: Pattern2
console.log("\nINHERITANCE Pattern2");

var Animal = function(name, weight) {
	this.name = name;
	this.weight = weight;
	console.log("Animal constructor");
};
Animal.prototype = {
	showData: function() {
		console.log("Animal: showData");
	},
	getName: function() {
		return this.name;
	}
};

var Cat = function() {
	Animal.apply(this, arguments);
};

Cat.prototype = Object.create(Animal.prototype);
Cat.prototype.constructor = Cat;

Cat.prototype = {
	showData: function() {
		console.log("Cat: showData");
	},
	getName: function() {
		return this.name;
	}
};

console.log("\nCreate bob");
var bob = new Animal("bob", 10.9);
console.log(bob.getName());
bob.showData();

console.log("\nCreate mie");
var mie = new Cat("mie", 3.5);
console.log(mie.getName());
mie.showData();

@@ -32,16 +32,21 @@
 le.log(%22
+=====
 INHERITA
@@ -57,16 +57,21 @@
 pattern1
+=====
 %22);%0Avar 
@@ -177,16 +177,33 @@
 %22);%0A%7D;%0A%0A
+// Defne methods%0A
 Parent.p
@@ -214,22 +214,18 @@
 type
- = %7B%0A%09
+.
 getName
-:
+ =
  fun
@@ -258,21 +258,37 @@
 me;%0A
-%09%7D,%0A%09
+%7D;%0A%0AParent.prototype.
 getAge 
-:
+=
  fun
@@ -320,21 +320,37 @@
 ge;%0A
-%09%7D,%0A%09
+%7D;%0A%0AParent.prototype.
 showData
 : fu
@@ -337,33 +337,34 @@
 ototype.showData
-:
+ =
  function() %7B%0A%09%09
@@ -400,15 +400,26 @@
 %22);%0A
-%09%7D%0A%0A%7D;%0A
+%7D;%0A%0A// Child class
 %0Avar
@@ -633,32 +633,50 @@
 is.name;%0A%09%7D%0A%7D;%0A%0A
+// Create objects%0A
 console.log(%22%5CnC
@@ -899,16 +899,21 @@
 .log(%22%5Cn
+=====
 INHERITA
@@ -924,20 +924,41 @@
 Pattern2
-%22);%0A
+=====%22);%0A%0A// Animal class
 %0Avar Ani
@@ -1081,38 +1081,33 @@
 al.prototype
- = %7B%0A%09
+.
 showData
 : function()
@@ -1086,33 +1086,34 @@
 ototype.showData
-:
+ =
  function() %7B%0A%09%09
@@ -1141,37 +1141,54 @@
 showData%22);%0A
-%09%7D,%0A%09
+%7D;%0A%0AAnimal.prototype.
 getName
-:
+ =
  function() 
@@ -1205,27 +1205,24 @@
  this.name;%0A
-%09%7D%0A
 %7D;%0A%0Avar Cat 
@@ -1272,16 +1272,29 @@
 s);%0A%7D;%0A%0A
+// Cat class%0A
 Cat.prot
@@ -1377,38 +1377,33 @@
 at.prototype
- = %7B%0A%09
+.
 showData
 : function()
@@ -1382,33 +1382,34 @@
 ototype.showData
-:
+ =
  function() %7B%0A%09%09
@@ -1434,37 +1434,51 @@
 showData%22);%0A
-%09%7D,%0A%09
+%7D;%0A%0ACat.prototype.
 getName
-:
+ =
  function() 
@@ -1495,27 +1495,24 @@
  this.name;%0A
-%09%7D%0A
 %7D;%0A%0Aconsole.
@@ -1512,26 +1512,24 @@
 onsole.log(%22
-%5Cn
 Create bob%22)
@@ -1526,16 +1526,18 @@
 eate bob
+%5Cn
 %22);%0Avar 
@@ -1621,26 +1621,24 @@
 onsole.log(%22
-%5Cn
 Create mie%22)
@@ -1635,16 +1635,18 @@
 eate mie
+%5Cn
 %22);%0Avar 

Update inheritance.js