update:demo3

This commit is contained in:
dichgrem
2025-11-14 15:36:43 +08:00
parent d765c1a219
commit c20e8949a5
22 changed files with 310 additions and 0 deletions

61
com/study/demo3/Book.java Normal file
View File

@@ -0,0 +1,61 @@
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.");
}
}
}