Pholimolphysome in JavaScript

 

In this article going to show what exactly pholimolphysome and implementation in javaScrip

In a simple word pholimolphysome is the provision of a single interface to entities of different types.

 

Example

class Car {
  constructor(name, model) {
    this.name = name;
    this.model = model;
  }

  startEngine() {
    console.log(`${this.name}'s engine has been started`);
  }

  stopEngine() {
    console.log(`${this.name}'s engine has been stoped`);
  }

  showCarInfo() {
    console.log(`Car name: ${this.name} - car Model: ${this.model}`);
  }

}

class Tesla extends Car {

  constructor(name, model, speed) {
    super(name, model);
    this.speed = speed;
  }

  // This called method overriding
  showCarInfo() {
    console.log(
      `Car name: ${this.name} - Model: ${this.model} - Speed: ${this.speed}`
    );
  }
}

const ob = new Tesla(`Nikola Tesla`, `Tesla Model S`, 250);
ob.startEngine();
ob.stopEngine();
ob.showCarInfo();

 

About Author

Photo

Hi, I am Mahbub Hasan
Software Engineer

I am very much interested to share my programming
and development knowledge with the people.I will try
to update my blog everyday with new technology inshallah.

Thank You

For Visiting My Blog.

Contact Me