81 lines
1.8 KiB
Java
81 lines
1.8 KiB
Java
/**
|
|
* Assignment 21
|
|
* Skill: CISS238
|
|
* Student: Scott Steely
|
|
* Date: Oct 07, 2025
|
|
*/
|
|
|
|
package dropbox21;
|
|
import java.time.LocalDate;
|
|
|
|
public class Book {
|
|
|
|
//fields
|
|
private boolean NEEDS_UPDATE = false;
|
|
private String isbn;
|
|
private String title;
|
|
private String author;
|
|
private int copyright_year;
|
|
|
|
//accessors
|
|
public String getISBN() {
|
|
return isbn;
|
|
}
|
|
public String getTitle() {
|
|
return title;
|
|
}
|
|
public String getAuthor() {
|
|
return author;
|
|
}
|
|
public int getCopyright_Year() {
|
|
return copyright_year;
|
|
}
|
|
|
|
//mutators
|
|
public void setISBN(String isbn) {
|
|
this.isbn = isbn;
|
|
}
|
|
public void setTitle(String title) {
|
|
this.title = title;
|
|
}
|
|
public void setAuthor(String author) {
|
|
this.author = author;
|
|
}
|
|
public void setCopyright_Year(int copyright_year) {
|
|
this.copyright_year = copyright_year;
|
|
}
|
|
|
|
//constructor
|
|
public Book() {
|
|
}
|
|
public Book(String isbn, String title, String author, int copyright_year) {
|
|
this.isbn = isbn;
|
|
this.title = title;
|
|
this.author = author;
|
|
this.copyright_year = copyright_year;
|
|
}
|
|
|
|
//method
|
|
public boolean needsUpdate() {
|
|
LocalDate currentDate = LocalDate.now();
|
|
int currentYear = currentDate.getYear();
|
|
if(currentYear - getCopyright_Year() > 3) {
|
|
NEEDS_UPDATE = true;
|
|
}
|
|
return NEEDS_UPDATE;
|
|
}
|
|
|
|
// toString
|
|
@Override
|
|
public String toString() {
|
|
String str;
|
|
str = String.format("%12s%-10s%n%12s%-10s%n%12s%-10s%n%12s%-10s%n%12s%-10s%n",
|
|
"ISBN: ", getISBN(),
|
|
"Title: ", getTitle(),
|
|
"Author: ", getAuthor(),
|
|
"Copyright: ", getCopyright_Year(),
|
|
"Update req: ", needsUpdate()?"Yes":"No");
|
|
return str;
|
|
}
|
|
}
|