java report
java report
On
LIBRARY BOOK ISSUES MANAGEMENT SYSTEM
Prepared By:
ISHA H. GOHEL – (236200316063)
Guided By
Shraddha Parmar
Information Technology Department
Government Polytechnic Rajkot
Information Technology Department Object
Oriented Programming with JAVA
(4341602) Semester 4th
Certificate
This is to certify that below students of fourth semester of diploma
in Information Technology of the Institute Government Polytechnic
Rajkot has successfully completed the micro- project in Object
Oriented Programming with Java (4341602) for the academic year
2024-25.
Sr no. Enroll No. Name Div
1 236200316063 Isha Gohel IT-A
// Custom Exceptions
class BookNotFoundException extends Exception
{ public BookNotFoundException(String message) {
super(message);
}
}
// Book class
class Book {
int bookId;
String title;
boolean available;
// Member class
class Member {
int memberId;
String name;
// Library class
class Library
{ List<Book> books;
List<Member> members;
public Library() {
this.books = new ArrayList<>();
this.members = new ArrayList<>();
}
// Main class
public class LibraryManagementSystem
{ public static void main(String[] args) {
Library library = new Library();
library.addBook(book1);
library.addBook(book2);
library.addMember(member1);
library.addMember(member2);
library.displayAvailableBooks();
try {
library.borrowBook(1, 101);
library.borrowBook(2, 102);
} catch (BookNotFoundException | BookUnavailableException e)
{ System.out.println("Error: " + e.getMessage());
}
library.displayAvailableBooks();
try {
library.returnBook(1);
} catch (BookNotFoundException e)
{ System.out.println("Error: " + e.getMessage());
}
library.displayAvailableBooks();
}
}
OUTPUT:
Available Books:
Book ID: 1, Title: Java Programming
Book ID: 2, Title: Data Structures and Algorithms
Book with ID 1 borrowed by Member101
Book with ID 2 borrowed by Member102
Available Books:
Book with ID 1 returned successfully.
Available Books:
Book ID: 1, Title: Java Programming
Book Class: la book with attributes like bookld, title, and available status.
CUSTOM EXCEPTIONS:
BookNotFoundException & BookUnavailableException
These are custom exception classes that extend Java’s Exception class.