Your cart is currently empty!
Restrictions: You cannot use any methods from the Java Arrays class to copy an array, check for equality, or otherwise manipulate an array. You must write the Java code to perform these functions. Note that this does not mean that you cannot use an Array, merely that you cannot call any of the static methods…
Restrictions:
You cannot use any methods from the Java Arrays class to copy an array, check for equality, or otherwise manipulate an array. You must write the Java code to perform these functions. Note that this does not mean that you cannot use an Array, merely that you cannot call any of the static methods of the Arrays class.
In this project you will be doing the following:
Create a NetBeans project named lab02 and ensure it is imported into Subversion.
In this assignment you will be creating a generic interface GenericBag which would be a collection of items that the client would define. The GenericBag interface will be a generic interface with a Type Parameter. Just like in lab01, Bag will not order the items in any particular order nor does it prevent any duplicates. You may reuse the code from the lab01 assignment for the Bag interface if you’d like as it is the same. Provide the following methods in the interface:
Develop a Generic interface named GenericBag that can store certain number of items (type will be specified by the client). Provide the following methods in the interface. You can copy your code from the previous assignment.
Implement the generic SinglyLinkedList class from chapter 3.2.1. You may copy the code from the book when doing so, but you may want to attempt to implement it yourself first. We will be inheriting from this class later so you should make the field values protected instead of private.
Design a generic class called LinkedBag which extends the generic SinglyLinkedList class and implements the GenericBag interface.
Create a user-defined class called Student. Each Player object will have the following attributes (instance variables): name, ID, and GPA. Use appropriate data types to define these instance variables and use recommended naming conventions for the variable names.
Provide a constructor, implement the accessor and mutator methods for each of the instance variables, and include the toString( ) and equals( ) methods. For the equals method, you can assume that two students are the same if they have the same name and ID.
Also include a static factory method that can be used to generate instances of the Student class. This method should create a student with a random name, ID, and GPA and return that student object.
Finally, create a Client Program BagClient with the main( ) method. Inside the main method do the following:
Comment your GenericBag interface, LinkedBag and Student classes with Java Doc commenting style. Use single line or block style comments as necessary or appropriate for the BagClient program.
Using Microsoft Visio draw a UML class diagram displaying all the classes and the relationships between them.
For this diagram include the client class. The contents of the client class can just be the main( ) method. This class will have association relationships between SinglyLinkedList, LinkedBag, and Student classes. You should include your interface in the diagram as well.
An association relationship simply means that a class uses another class – In this project, Client class is using LinkedBag and Student. This is depicted by an undirected solid line connecting the two classes.
Things to turn in: