-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryManagementSystem.java
More file actions
48 lines (40 loc) · 1.48 KB
/
Copy pathLibraryManagementSystem.java
File metadata and controls
48 lines (40 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Book class to represent library books
class Book {
// Static variable for library name
public static String libraryName = "City Library";
// Instance variables
private String title;
private String author;
private final String isbn; // Final variable for unique book identifier
// Constructor using 'this' keyword
public Book(String title, String author, String isbn) {
this.title = title;
this.author = author;
this.isbn = isbn;
}
// Static method to display library name
public static void displayLibraryName() {
System.out.println("Library Name: " + libraryName);
}
// Method to display book details
public void displayBookDetails() {
if (this instanceof Book) {
System.out.println("Book Details - Title: " + title + ", Author: " + author + ", ISBN: " + isbn);
}
}
}
public class LibraryManagementSystem {
public static void main(String[] args) {
// Display library name
Book.displayLibraryName();
// Create and display book instances
Book book1 = new Book("Core Java", "James Goshling", "978-01");
Book book2 = new Book("Advance Java", "Goshling James", "978-02");
book1.displayBookDetails();
book2.displayBookDetails();
}
}
//Sample Output
//Library Name: City Library
//Book Details - Title: Core Java, Author: James Goshling, ISBN: 978-01
//Book Details - Title: Advance Java, Author: Goshling James, ISBN: 978-02