This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

OO Design issue with Data and RMI instance??

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following problems see below..
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public interface DataClient extends Remote
{
public FieldInfo [] getFieldInfo()throws RemoteException;
public DataInfo getRecord(int recNum)throws DatabaseException, RemoteException;
public DataInfo find(String toMatch)throws DatabaseException, RemoteException;
public void add(String [] newData)throws DatabaseException, RemoteException;
public void modify(DataInfo newData)throws DatabaseException, RemoteException;
public void delete(DataInfo toDelete)throws DatabaseException, RemoteException;
public void close() throws RemoteException;
public void lock(int record)throws IOException, RemoteException;
public void unlock(int record)throws RemoteException;
public DataInfo[] criteriaFind(String criteria) throws DatabaseException, RemoteException;
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getMatchCount(String matchCount) throws DatabaseException,RemoteException;
}

package suncertify.db;
import java.io.*;
import java.util.*;
public class DataClientLocal implements DataClient
{
public DataClientLocal(String dbname){
try
{
Data dbInstance = new Data(dbname);
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}
}
}
//next code>DataClientRMI
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public class DataClientRMI implements DataClient
{
public DataClientRMI(){
try
{
////////
}
catch(Exception ex)
{
System.out.println("Database connection failed");
}
}
}

then on the client:::::
public switchMode
{
DataClient data =null;
if(localmode)
{
data = new DataClientLocal(arg1,...)
}
else
{
data = new DataClientRMI(arg1,...)
}
}
Problem is when I try to compile these above classes::
DataClientRMI
DataClientLocal
//I get the errors these two classes must be declared abstract but if I do this I cant create an instance of these 2 classes in myabove switchMode().
Any suggestions or solutions for my code.Perhaps I am missing something here???
Thanks Lisa

 
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you implement all methods in in the interface ? If you did not implement all methods in an interface your class implemented, you will get such error message you had.
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you implemented all methods in the interface ? If you did not implement all methods in the interface, you will get such error message when you compile your class.

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must implement all your classes. Take a carefull look to your class implmentations again
------------------
------------------------
Koray G��l�
(B.s. Computer Engineer)
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming that you intentionally do not want to implement all the methods that you have defined in your interface. One solution is to go back and implement all the methods of the interface. The other solution is to define an Adapter class. This class implements the interface and has empty implements for each. You can then subclass that adapter and define only those methods that you want. So first decide whether you want to implement all the methods or not.
 
    Bookmark Topic Watch Topic
  • New Topic