Interface ... extends ... implements ... (Need help)

Reply

Join Date: Oct 2006
Posts: 11
Reputation: balgarath is an unknown quantity at this point 
Solved Threads: 0
balgarath balgarath is offline Offline
Newbie Poster

Interface ... extends ... implements ... (Need help)

 
0
  #1
Nov 6th, 2007
Its been years since I've used Java, this one is stumping me...

I implemented my own Observer/Observable interfaces for use with a 2-way RMI setup(I'm sure theres a better name but I don't know it yet).
I have 2 interfaces ToyStore and ToyFactory. ToyStore extends Remote implements Observer, ToyFactory extends Remote implements Observable. I then have a Server class that implements ToyFactory and a Client class that implements ToyStore(I won't post the code for these 2 yet, I don't think its the problem but if need be I can post).


This is what I get when I compile:
  1. $ javac -d ./test Client.java Server.java Observable.java Observer.java ToyFactory.java ToyStore.java
  2. ToyFactory.java:7: '{' expected
  3. extends Remote
  4. ^
  5. ToyStore.java:7: '{' expected
  6. extends Remote
  7. ^
  8. 2 errors
Observer.java
  1. package toys;
  2.  
  3. public interface Observer
  4. {
  5. public void update(Observable o);
  6. }
Observable.java
  1. package toys;
  2.  
  3. public interface Observable
  4. {
  5. public void addObserver(String s);
  6. }
ToyStore.java
  1. package toys;
  2.  
  3. import java.rmi.Remote;
  4. import java.rmi.RemoteException;
  5.  
  6. public interface ToyStore
  7. extends Remote
  8. implements Observer
  9. {
  10. String sayHi() throws RemoteException;
  11. public void update(Observable o) throws RemoteException;
  12. }
ToyFactory.java
  1. package toys;
  2.  
  3. import java.rmi.Remote;
  4. import java.rmi.RemoteException;
  5.  
  6. public interface ToyFactory
  7. extends Remote
  8. implements Observable
  9. {
  10. String sayHello() throws RemoteException;
  11. public void addObserver(String s) throws RemoteException;
  12. }
Am I compiling this wrong? Am I allowed to extend and implement in an interface? Does extending Remote block me from Implementing Observer/Observable? Missing semicolon? Let me know if I need to post the other 2 files...Thanks for the help.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,356
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Interface ... extends ... implements ... (Need help)

 
0
  #2
Nov 6th, 2007
An interface cannot implement anything, since an interface is not an implementation. An interface can only extend interfaces (exactly one).

Edit:

PS If you are a David Eddings fan, it is spelled Belgarath not Balgarath. If not, then please ignore.
Last edited by jwenting; Nov 6th, 2007 at 12:49 pm. Reason: PS it's implementation, not implementattion, and you instead of you
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 11
Reputation: balgarath is an unknown quantity at this point 
Solved Threads: 0
balgarath balgarath is offline Offline
Newbie Poster

Re: Interface ... extends ... implements ... (Need help)

 
0
  #3
Nov 6th, 2007
Thanks a lot...I didn't really need the Observer/Observable files anyway I can just make ToyFactory and ToyStore require those methods.

David Eddings fan - yes, great books.

I spelled it that way on purpose, used that name in Ultima Online years ago and it kind of stuck.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,356
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 252
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Interface ... extends ... implements ... (Need help)

 
0
  #4
Nov 6th, 2007
Originally Posted by balgarath View Post
David Eddings fan - yes, great books.

I spelled it that way on purpose, used that name in Ultima Online years ago and it kind of stuck.
Just wanted to check that that was what it looked like. ;-)
Last edited by masijade; Nov 6th, 2007 at 2:29 pm.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC