-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbook.java
32 lines (30 loc) · 867 Bytes
/
book.java
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
public class Book {
String title, author, ISBN;
int numCopies;
public Book(String title, String author, String ISBN, int numCopies) {
this.title = title;
this.author = author;
this.ISBN = ISBN;
this.numCopies = numCopies;
}
public Book() {
this.title = null ;
}
public void borrow(){
if(numCopies > 0){
this.numCopies--;
}
else {
System.out.println("Error: Book not available for borrowing");
}
}
public void returnBook(){
this.numCopies++;
}
public void display(){
System.out.println("Title : " + title + "\n"+"Author : " +author+"\n"+"ISBN : " + ISBN +"\n"+"Number of copies available :" + numCopies +"\n");
}
public String getTitle() {
return title;
}
}