73 lines
1.4 KiB
Java
73 lines
1.4 KiB
Java
|
|
/**
|
|
* Subclass of LibraryItem that emulates a Book item.
|
|
*
|
|
* @George Wilkinson
|
|
* @2.3
|
|
*/
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class Book extends PrintedItem
|
|
{
|
|
private String author;
|
|
private String isbn;
|
|
|
|
/**
|
|
* Constructor for objects of class Book
|
|
* Since all field variables initialise as null, nothing should happen here.
|
|
*/
|
|
public Book(){}
|
|
|
|
/*
|
|
* Return value of @author
|
|
*/
|
|
public String getAuthor()
|
|
{
|
|
return author;
|
|
}
|
|
|
|
/*
|
|
* Return value of @isbn.
|
|
*/
|
|
public String getIsbn()
|
|
{
|
|
return isbn;
|
|
}
|
|
|
|
/*
|
|
* Set value of @author.
|
|
*/
|
|
public void setAuthor( String author )
|
|
{
|
|
this.author = author;
|
|
}
|
|
|
|
/*
|
|
* Set value of @isbn
|
|
*/
|
|
public void setIsbn( String isbn )
|
|
{
|
|
this.isbn = isbn;
|
|
}
|
|
|
|
/*
|
|
* Print to terminal, relevant details of current object.
|
|
*/
|
|
public void printDetails() {
|
|
System.out.println( "ISBN: " + isbn +
|
|
"\nAuthor: " + author );
|
|
super.printDetails();
|
|
}
|
|
|
|
/*
|
|
* Passed a scanner object, set field variables to corresponding values.
|
|
*/
|
|
public void readItemData( Scanner detailScanner ){
|
|
if ( detailScanner != null ) {
|
|
this.author = detailScanner.next().trim();
|
|
this.isbn = detailScanner.next().trim();
|
|
super.readItemData( detailScanner );
|
|
}
|
|
}
|
|
} |