Question

In: Computer Science

You have a program which has an interface for a remote public interface Remote { public...

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.

Solutions

Expert Solution

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.


Related Solutions

20. Assume you have a Java Interface with a method has this signature: public double min(double......
20. Assume you have a Java Interface with a method has this signature: public double min(double... grades); Write the implementation of this method so that it returns the smallest of the grades. Show example on calling the method when you are done with the implementation.
package design; public interface Employee { /*Employee is an Interface which contains multiple unimplemented methods.Again few...
package design; public interface Employee { /*Employee is an Interface which contains multiple unimplemented methods.Again few methods has been declared in below. you need to brainstorm to add more methods to meet the business requirements. */ //please read the following method and understand the business requirements of these following methods //and then implement these in a concrete class. //employeeId() will return employee id. public int employeeId(); //employeeName() will return employee name public String employeeName(); //assignDepartment() will assign employee to departments...
Consider the following interface: public interface Car{ public String getMake(); public void setMake(); public void honk();...
Consider the following interface: public interface Car{ public String getMake(); public void setMake(); public void honk(); public void crash(); public void drive(); } public interface Boat{ public String getMake (); public void setMake (); public void blast_horn(); public void sink(); public void move(); } 1. Create a concrete FamilyCar class from the Car interface.
You have been asked to set-up remote meetings due to the spread COVID-19. Share which remote...
You have been asked to set-up remote meetings due to the spread COVID-19. Share which remote learning program you will utilize and explain why you selected the option. Your response must consist of a minimum of 15 complete sentences.
In Java Create an interface Create an interface Printing, which have a method getPageNumber () that...
In Java Create an interface Create an interface Printing, which have a method getPageNumber () that return page number of any printing. Create an abstract class named Novel that implements Printing. Include a String field for the novel's title and a double field for the novel price. Within the class, include a constructor that requires the novel title, and add two get methods--one that returns the title and one that returns the price. Include an abstract method named setPrice().. Create...
Write the program in Java (with a graphical user interface) and have it calculate and display...
Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. Allow the user to loop back and enter new data or quit. You need to include Calculate, Reset, and Exit buttons on your GUI. Please insert comments in the program to document the program. Allow the user to enter...
(Implementing Interfaces) Implement the following interface and classes: a. Interface IsCompetition, which has no constants and...
(Implementing Interfaces) Implement the following interface and classes: a. Interface IsCompetition, which has no constants and two methods (see the classes below for details about what these methods should do): i. getSummary(), ii. getCompetitors() b. Class Game: A game object is associated with a home team, away team, home score, away score, and a date of competition. It should only be created using the following constructor: Game(String HTeam, String ATeam, int HScore, int AScore, LocalDate date). A game is also...
130 Submit Copy your public key which is in ~/.ssh/id_rsa.pub to the remote machine by completing...
130 Submit Copy your public key which is in ~/.ssh/id_rsa.pub to the remote machine by completing this command: scp ~/.ssh/id_rsa.pub [email protected]:_____/_____
Finish the following java question: Consider the following interface: interface Duty { public String getDuty(); }...
Finish the following java question: Consider the following interface: interface Duty { public String getDuty(); } Write a class called Student which implements Duty. Class Student adds 1 data field, id, and 2 methods, getId and setId, along with a 1-argument constructor. The duty of a Student is to study 40 hours a week. Write a class called Professor which implements Duty. Class Professor adds 1 data field, name, and 2 methods, getName and setName, along with a 1-argument constructor....
write JAVA program have a public class named GeometricShapes that has the main() method. In the...
write JAVA program have a public class named GeometricShapes that has the main() method. In the main() method the user needs to select if he want 2D shapes or 3D shape -if user select 2D user needs to select the shape type (Square, Circle, or Triangle) after selected shape the user needs to specify whether to find the Area or the Perimeter or to find side-length (radius for the circles), accordingly the needed constructor is used. (using Polymorphism principle) -if...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT