vault backup: 2024-09-05 17:56:43
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
|
||||
/**
|
||||
* Subclass of LibraryItem that emulates a Book item.
|
||||
*
|
||||
* @George Wilkinson
|
||||
* @2.5
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the fields with details from the scanner
|
||||
* Takes Parameters
|
||||
* Scanner @detailScanner
|
||||
*/
|
||||
public void readItemData( Scanner detailScanner ){
|
||||
if ( detailScanner != null ) {
|
||||
this.author = detailScanner.next().trim();
|
||||
this.isbn = detailScanner.next().trim();
|
||||
super.readItemData( detailScanner );
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user