Here is an excerpt from my code
package dictionary; import java.util.Iterator; import java.util.LinkedList; import java.util.regex.*; public class IntelliCwDB extends CwDB { public IntelliCwDB(String filename) { super(filename); } @Override public void add(String word, String clue) { System.out.println("inelli"); } }
And CwDB ...
package dictionary; import java.util.LinkedList; import java.io.*; import java.util.Scanner; public class CwDB { protected LinkedList<Entry> dict; public CwDB(String filename) { dict = new LinkedList<Entry>(); createDB(filename); } public void add(String word, String clue) { System.out.println("cwdb"); dict.add(new Entry(word, clue)); } protected void createDB(String filename) { try { BufferedReader f = new BufferedReader(new FileReader(filename)); while (f.ready()) { this.add(f.readLine(), f.readLine()); } } catch (Exception e) { e.printStackTrace(); } } }
In the main() I create a new IntelliCwDB object that starts the execution of createDB() .
The problem is that I want CwDB.createDB() use the native CwDB.add() method, and not the one that was from IntelliCwDB . Is there another neat solution than creating CwDB separately and then passing it to the IntelliCwDB constructor to rewrite the LinkedList<Entry> dict database?
source share