Professional Documents
Culture Documents
Assignment Unit 6 Ex
Assignment Unit 6 Ex
This assignment demonstrates a generic library catalog implemented in Java with example code
and output.
Objectives:
Develop a catalog that can store books and DVDs (expandable to other types).
public LibraryCatalog() {
}
// Method to add a new library item
catalog.put(item.getItemID(), item);
if (catalog.containsKey(itemID)) {
T removedItem = catalog.remove(itemID);
} else {
if (catalog.containsKey(itemID)) {
T item = catalog.get(itemID);
} else {
if (catalog.isEmpty()) {
System.out.println("Catalog is empty.");
} else {
System.out.println("Current Catalog:");
System.out.println("--------------------");
```
Example Code Usage:
bookCatalog.viewCatalog();
bookCatalog.removeItem(102);
bookCatalog.viewCatalog();
```
Output:
```
Current Catalog:
Title: Book1
Author: Author1
--------------------
Title: Book2
Author: Author2
--------------------
Title: Book3
Author: Author3
--------------------
Current Catalog:
Title: Book1
Author: Author1
--------------------
Title: Book3
Author: Author3
--------------------
```