Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi! I need help making a java program. Can someone show me an example of the bel

ID: 3618512 • Letter: H

Question

Hi! I need help making a java program. Can someone show me an example of the below? Thank you! Write two interfaces that each include 1 or more abstract methods. The interfaces cannot be ones that we used as examples in class or that are from our textbook (e.g. Movable, Locatable, or Measurable). Design & implement 2 unrelated classes that realize both interfaces as well as the Comparable interface. For example, while the classes Helicopter and Lizard are not related to each other they would both implement Movable and Locatable. Each of your two classes must include at least one interesting method that is not found in one of the interfaces. Finally, write a client program named Interfaces Test that instantiates two objects from each of the two classes and that uses all available methods from those classes (included the compare To method).

Explanation / Answer

publicinterface A { publicabstract void A(); } public interface B { publicabstract void B(); } public class Aclass implements A, Comparable { privateint value; publicAclass(int v) { value = v; } publicint compareTo(A rhs) { return getValue() -rhs.getValue(); } publicint getValue() { return value%10; } publicvoid A() { System.out.println(-getValue()); } } public class Bclass implements B, Comparable { privateint value; publicBclass(int v) { value = v; } publicint compareTo(B rhs) { return getValue() -rhs.getValue(); } publicint getValue() { return value/10; } publicvoid B() { System.out.println(getValue()*8); } } public class InterfacesTest { publicstatic void main(String[]args) { A a1 = new A(17); A a2 = new A(25); System.out.println(a1.getValue()); System.out.println(a2.getValue()); System.out.println(a1.compareTo(a2)); a1.A(); a2.A(); B b1 = new B(17); B b2 = new B(25); System.out.println(b1.getValue()); System.out.println(b2.getValue()); System.out.println(b1.compareTo(b2)); b1.B(); b2.B(); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote