Hi,
So I have two classes. One is abstract:
public abstract class AbstractClient {
protected boolean running = true;
protected void run() {
Scanner scanner = new Scanner(System.in);
displayOptions();
while (running) {
String input = null;
while (scanner.hasNext()) {
input = scanner.next();
}
processInputCommand(input);
}
}
abstract void displayOptions();
abstract void processInputCommand(String input);
}
One is the concrete subclass:
public class BasicClient extends AbstractClient {
private IBasicServer basicServer;
public static void main(String[] args) {
new BasicClient();
}
public BasicClient() {
try {
System.setSecurityManager(new RMISecurityManager());
Registry registry = LocateRegistry.getRegistry();
basicServer = (IBasicServer) registry.lookup(IBasicServer.LOOKUPNAME);
run();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
void displayOptions() {
BasicClientOptions.displayOptions();
}
@Override
void processInputCommand(String input) {
// TODO Auto-generated method stub
}
}
Now in the subclass I call the run() method of the abstract class because this should be common to all clients. Inside the run() method is a call to the abstract method displayOptions().
I have overridden displayOptions() in the subclass so I assumed that it would invoke the subclassed method but it seems it has not. Is there a way to do this or have I made an obvious mistake or have I misunderstood how abstract classes should work?
P.S I tried putting a print statement inside the subclassed displayOptions() to ensure I hadn't done something daft with method I call.
Many thanks,
Adam