dimanche 31 mars 2019

Is this an interface, i am trying to do or have speculated of an interface?

i have preferred this answer for understanding and it's intuitive and have come up with some speculation which i need to be assure of.

What is the definition of "interface" in object oriented programming

it says In object oriented programming, an interface generally defines the set of methods (or messages) that an instance of a class that has that interface could respond to

consider this example A class car

class Car{
    function start(){
       print('travelling by car');
}

A class travel

 class Travel{

 protected travel;
 public function travelling('type'){
      if(type==car){
       $this->travel=new car;
         }
       $this->travel->start()
    }

 }

An index

  $travel_obj=new Travel;
  $travel_obj->travelling('car');

(please ignore all other concept standarisation and dependency injection)

Can i say that i made interface between travelling class and car class and the interface is made by passing the some string though it is not making sense of an interface rule like have some standarisation but it is interface between travel class and car class.

Can i say that is if this was an interface of standarisation the only way to make interface is passing as argument like here we passing like a string. is there any other way which i should know.

thank you in advance good peoples.

Aucun commentaire:

Enregistrer un commentaire