mardi 6 octobre 2015

Have I implemented adapter pattern correctly?

These are my .java classes. I wanna make sure that I have implemented the adapter pattern correctly.

I'd appreciate if someone could guide me whether there's something wrong in the code or not.

Adapter.java

public class Adapter implements Play{

AdvanceTuning aTune;

public Adapter(String Type){

    if(Type.equalsIgnoreCase("Sharp")){

        aTune= new SharpTuning();
    }
    else if(Type.equalsIgnoreCase("LowKey")){
        aTune= new LowKeyTuning();
    }
}

@Override
public void Tune(String Type,String Guitar) {
    // TODO Auto-generated method stub
    if(Type.equalsIgnoreCase("Sharp")){
        aTune.getSharp(Guitar);
    }
    else if(Type.equalsIgnoreCase("LowKey")){
        aTune.getLowKey(Guitar);
    }
}
}

Aucun commentaire:

Enregistrer un commentaire