lundi 16 janvier 2023

Designs Patterns?

I'm trying to write a generic code. Here is my scenario.

class AEvent {

  public void onAEventCreate( A event){
     //do something
  }

}

class BEvent {

   public void onBEventCreate (B event) {
   //do something
   }

}

I want to have some generic class which could do the operation of method onAEventCreate and onBEventCreate on one single method. Now the problem is I cannot change the classes AEvent and BEvent . Is there a way I can listen to the two methods? or is there some kind of design pattern maybe like observer which can help me achieve this.

Aucun commentaire:

Enregistrer un commentaire