stefanos1316 / Rosetta_Code_Research_MSR

Exploiting Programming Languages Energy Consumption
4 stars 2 forks source link

Inheritance Single #4

Closed stefanos1316 closed 7 years ago

stefanos1316 commented 7 years ago

function Animal() { // ... }

function Dog() { // ... }

function Lab() { // ... }

function Collie() { // ... }

function Cat() { // ... }

Animal.prototype.speak = function() {console.log("Animal speaking")}; Animal.prototype.walk = function() {console.log("Animal walking")}; Dog.prototype.speak = function() {console.log("Dog barking")}; Lab.prototype.speak = function() {console.log("Lab barking")}; Collie.prototype.speak = function() {console.log("Collie barking")}; Cat.prototype.speak = function() {console.log("Cat Meawing")};

var lab = new Dog(); lab.speak(); // shows "an animal makes a sound" //lab.walk();

this is the current code, however, it is not possible to use inheritance on JS as far as I know.

stefanos1316 commented 7 years ago

Fixed, I read some of the instruction from this link