help with this pakages stuff
The program will consist of three classes: Student, ArrayListWrapper, and Demo. Demo will have the main method. These classes will not be related by inheritance. All classes will be in one
package, with a name of your choice.
Class Student will have the following object fields:
Name, String
HoursEnrolled, Integer (not int)
Cloned, boolean, indicating whether the object has been cloned
Student will implement interface Copyable, defined as follows:
public interface Copyable extends Cloneable {
public Object clone();
public void show();
}
The show method will write a Student to the console in the format "class=<class name>
Name=<Name> <Hours enrolled=<HoursEnrolled> Cloned=<Cloned>". The class name will be
obtained using getClass().getName(). The Clone method will make copies of all mutable field
objects and will set the cloned field to true. Class Student will also override the equals method
of the Object class, with an Object as the method parameter, not a Student. Two students will be
equal if they have the same names, case sensitive.
Student will have any other methods necessary.
Class Demo will implement interface CopyListener, defined as follows:
public interface CopyListener {
public void copyAdded(Copyable obj);
}
The copyAdded method will be called by an ArrayListWrapper object (see below) when it adds
an object. The copyAdded method will output the message "Added <text>", where <text> is the output
of the added object's show() method.
Class ArrayListWrapper will have the following object fields:
An array of CopyListeners
An ArrayList.
Class ArrayListWrapper will have the following public object methods:
Default constructor.
void addListener(CopyListener listener), which adds a CopyListener listener to
the ArrayListWrapper's array. Each of these listeners will be objects which should be notified,
via the copyAdded method, when an object is added to the ArrayListWrapper.
void add(Copyable obj), which adds an object to the ArrayList, if the object does not already exist in the ArrayList. When an object is added, it will first be cloned, then the clone added (not the original object). If the object is added, the copyAdded method will be called for the ArrayListWrapper's listeners.
void show(), which outputs all the objects in the ArrayList, using the objects' show method. ArrayListWrapper can have other private fields or methods if you want, but no other non-private methods. ArrayListWrapper be written such that it makes no references to the Student or Demo classes.
The main method of the Demo class will do the following:
Create two Demo objects and a ArrayListWrapper object
Add the Demo objects to the ArrayListWrapper as listeners
Create three students with different names and different hours enrolled, and add each to the ArrayListWrapper
Create another student with the same name as one of the previous three students, and try to add it to
the ArrayListWrapper using the add method
Show the ArrayListWrapper using its show method

