Assignment Unit 6
Assignment Unit 6
This program implements a generic library catalog that can store information about different
1. LibraryItem Class:
genre) {
this.title = title;
this.author = author;
this.itemID = itemID;
this.genre = genre;
}
2. Generic Catalog Class:
public LibraryCatalog() {
items.add(item);
T removedItem = null;
if (items.get(i).getItemID().equals(itemID)) {
removedItem = items.get(i);
index = i;
break;
if (index == -1) {
not found.");
}
items.remove(index);
return removedItem;
return items;
3. ItemNotFoundException:
super(message);
this.catalog = catalog;
int choice;
do {
System.out.println("4. Exit");
choice = scanner.nextInt();
switch (choice) {
case 1:
addItem();
break;
case 2:
removeItem();
break;
case 3:
viewCatalog();
break;
case 4:
break;
default:
System.out.println("Invalid Choice!");
5. Main Class:
menu.displayMenu();
}
Note: This is a basic example. You can extend the LibraryItem class with specific fields for
different item types (e.g., director for movies) and modify the addItem method in LibraryMenu to
viewing items with proper error handling using the ItemNotFoundException class.
This program demonstrates generic classes and methods for a library catalog with basic
functionalities. Compile and run the code to see the interactive menu and test the functionalities.