The following program is intended to manage a small list of names. The list itself is a static string array with only a few elements. This list is filled, emptied and read with some simple methods, each of which can throw one of the three exceptions of type ArrayFullException, ArrayEmptyException or EmptyElementException.
Complete the program and test it to the point where you have provoked each of the exceptions once.
Make an associated UML class diagram.
public class FreundeApp {
private static String[] friends = new String[3];
private static int friends = 0;
public static void main(String[] args) {
// Implement exception handling here, call the methods
// and provoke exceptions for testing purposes.
}
public static void addFriend(String name) throws ArrayFullException {
// Add a name to the array and increment the counter.
// But only if the array is not full yet.
}
public static void cleanArray() throws ArrayEmptyException {
// Delete all elements of the array and set the counter to 0.
// But only if the array is not empty yet.
}
public static String getFriend(int index) throws EmptyElementException {
// Read a name from the array and return it.
// But only if the element actually exists.
}
}