I have been set an assignment for my java course which involves creating a basic phone directory. I have come to the part which involves testing all of the methods inside my ArrayPhoneDirectory class, a class which implements an interface named PhoneDirectory.
I am stuck on how to instantiate the ArrayPhoneDirectory class within a separate tester class, as every attempt I have made has been returned with the error that it cannot be instantiated due to it being an abstract class.
PhoneDirectory interface code:
public interface PhoneDirectory {
/**
* Load file containing directory entries
*
* @param sourceName is name of the file containing the directory entries
*/
void loadData(String sourceName);
/**
* Look up an entry.
*
* @param name The name of person to look up
* @return The telno or null if name is not in the directory
*/
String lookUpEntry(String name);
**CODE SNIPPED**
ArrayPhoneDirectory code:
public abstract class ArrayPhoneDirectory implements PhoneDirectory {
private static final int INIT_CAPACITY = 100;
private int capacity = INIT_CAPACITY;
//holds telno of directory entries
private int size = 0;
//Array to contain directory entries
private DirectoryEntry[] theDirectory = new DirectoryEntry[capacity];
//Holds name of data file to be read
private String sourceName = null;
**CODE SNIPPED**
Any help with instantiating the ArrayPhoneDirectory class would be much appreciated, please comment if I need to add more of my code, i'm still fairly new to this!