vault backup: 2024-04-12 09:39:31

This commit is contained in:
2024-04-12 09:39:31 +01:00
parent e241fe8bd6
commit 30bfa6f243
73 changed files with 762 additions and 403 deletions

View File

@@ -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 );
}
}
}