mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-16 12:41:58 -05:00
58 lines
1.1 KiB
Java
58 lines
1.1 KiB
Java
package com.study.demo3;
|
|
|
|
public class Book {
|
|
protected String isbn;
|
|
protected String title;
|
|
protected boolean available;
|
|
|
|
public Book() {
|
|
this.available = true;
|
|
}
|
|
|
|
public Book(String isbn, String title) {
|
|
this.isbn = isbn;
|
|
this.title = title;
|
|
this.available = true;
|
|
}
|
|
|
|
public Book(String isbn, String title, boolean available) {
|
|
this.isbn = isbn;
|
|
this.title = title;
|
|
this.available = available;
|
|
}
|
|
|
|
public String getIsbn() {
|
|
return isbn;
|
|
}
|
|
|
|
public void setIsbn(String isbn) {
|
|
this.isbn = isbn;
|
|
}
|
|
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
|
|
public void setTitle(String title) {
|
|
this.title = title;
|
|
}
|
|
|
|
public boolean isAvailable() {
|
|
return available;
|
|
}
|
|
|
|
public void setAvailable(boolean available) {
|
|
this.available = available;
|
|
}
|
|
|
|
public void returnBook() {
|
|
if (!this.available) {
|
|
this.available = true;
|
|
System.out.println(
|
|
this.title + " (ISBN: " + this.isbn + ") has been returned and is now available.");
|
|
} else {
|
|
System.out.println(this.title + " (ISBN: " + this.isbn + ") is already available.");
|
|
}
|
|
}
|
|
}
|