This is my command interface
public interface IConverter {
void convert();
}
This is my Receiver class
public class Ogg extends Audio{
private File src;
private File trgt;
public static final String CODEC = "libvorbis";
public static final String FORMAT = "ogg";
public Ogg(File src, File trgt){
this.src = src;
this.trgt = trgt;
}
public void convertToOgg(){
audioAttr.setCodec(CODEC);
encoAttrs.setFormat(FORMAT);
encoAttrs.setAudioAttributes(audioAttr);
try {
encoder.encode(src, trgt, encoAttrs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
And this is my Concrete Command
package org.hitplay.audio.converters;
public class OggConverter implements IConverter {
private Ogg ogg;
public OggConverter(Ogg ogg){
this.ogg = ogg;
}
@Override
public void convert() {
ogg.convertToOgg();
}
}
And lastly this is my Invoker class.
public class AudioConverter {
IConverter audio;
public AudioConverter(IConverter audi){
this.audio = audi;
}
public void setAudio(IConverter audio){
this.audio = audio;
}
public void convert(){
audio.convert();
}
}
I have currently studied the Command Design Pattern on this link
And I was wondering if I have implemented the Design Pattern Correctly, if I do not please tell me why, and how else can I improve this code? also I have other classes besides Ogg and OggConverter I also have Mp3 and Mp3Converter
Commandto the classes that are commands. And work on your accept rate. – burna Jan 3 at 11:53