In: Computer Science
You have a program which has an interface for a remote
public interface Remote {
public void on();
public void off();
public void setChannel(int channel);
public int getChannel();
public void sleep(int numMinutes);
}
You've been working with a Spanish firm that wants to use your program, but they have a different interface
public interface controlRemoto {
public void enciende();
public void apague();
public void cambiaCanal(int channel);
public int qualCanal();
public void duerme(int numMinutes);
}
Create an adapter/wrapper around controlRemoto to make it look like Remote. For simplicity, the methods in both interfaces are in the correct order.
class RemoteAdapter implements controlRemoto { private Remote r; public RemoteAdapter(Remote r) { this.r = r; } public void enciende() { r.on(); } public void apague() { r.off(); } public void cambiaCanal(int channel) { r.setChannel(channel); } public int qualCanal() { return r.getChannel(); } public void duerme(int numMinutes) { r.sleep(numMinutes); } }
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.