Hello, I need help creating a Java class from a UML diagram using HashMap. Thank you.
Write a LibraryManager collection class that has a HashMap instance variable col that can contain LibraryItem objects.
Write a constructor for the LibraryManager class that instantiates the HashMap collection to an initial capacity of 500 items and load factor 0.6f.
The LibraryManager collection should also have these instance methods:
public void addItem(LibraryItem theBook)
Add a LibraryItem item to the HashMap collection using the catalogNum as the key.
public void clear()
Clear (remove) all LibraryItem objects from the HashMap. You can use the clear method of the HashMap to do this.
public ArrayList<LibraryItem> getAll()
Return a sorted ArrayList of all the objects in the HashMap.
public LibraryItem getByCatalogNum(int catalogNum)
Return the object from the HashMap with the given catalog number.
public ArrayList<LibraryItem> getByYear(int year)
Return a sorted ArrayList of objects from the HashMap that have the given year.
public ArrayList<LibraryItem> getCheckedOut()
Return a sorted ArrayList of objects from the HashMap that are checked out.
public int getCount()
Return the count of all the items in the HashMap.
public Iterable<LibraryItem> iterator()
{
return col.values().iterator();
}
Required method of the Iterable interface.
public void load()
Deserialize the objects from the disk file library-items.ser.
public void save()
Serialize the objects in the collection to the disk file library-items.ser.
Test your LibraryManager collection with the traditional test file Test1.java.
Add JavaDoc comments to the LibraryManager class so that the JavaDoc software can produce documentation. Run JavaDoc to produce documentation.
LibraryManager - col: HashMap<LibraryItem>
+ LibraryManager()
+ addItem(theBook: LibraryItem)
+ getAll(): ArrayList<LibraryItem>
+ getByCatalogNum(catalogNum: int): LibraryItem
+ getByYear(year: int): ArrayList<LibraryItem>
+ getCheckedIn(): ArrayList<LibraryItem>
+ getCheckedOut(): ArrayList<LibraryItem>
+ getCount(): int
+ iterator(): Iterable<LibraryItem>
+ load()
+ save()
1. n
LibraryItem
"interface, Iterable<LibraryItem>
interface" Serializable
+ iterator: Iterator<LibraryItem>
// No methods required