This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Interfaces still get me! I have a class ClassOne...
And then I have another class, ClassTwo.
I'd like to obtain a Sequencer instance of ClassOne, but does ClassOne need to implement the entire Sequencer interface (i.e. every single method) for this to be made (http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/midi/Sequencer.html)? I hoped that by calling MidiSystem.getSequencer() in ClassOne this would be suffice for ClassTwo's code to work, but I get the error "cannot find symbol" for 'new ClassOne()'.
What ought I be doing to get the Sequencer instance of ClassOne?
Ravaa Bal wrote:Hey guys, I have an issue with interfaces in general (didn't want to create a new topic for it).
If say I wanted to implement Sequencer after all like so:
First, don't do this. Your getLoopCount() will call getLoopCount() which will call getLoopCount() which will... you get the idea. An infinite recursive loop. What do you really want getLoopCount() to return?
Why do I get an error highlighting the implement line saying something like this?
"ClassOne is not abstract and does not override abstract method setLoopCount(int) in ...etc etc... Sequencer"
Looks like the method defined in the interface is:
And you are implementing a method like:
These aren't the same method. What is the difference? How do you fix it?
Joined: Apr 15, 2009
lol oh dear, thanks for pointing that out!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com