vault backup: 2024-02-20 13:05:19
This commit is contained in:
38
Semester 2/Programming 2/Project/Part 2/Book.java
Normal file
38
Semester 2/Programming 2/Project/Part 2/Book.java
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
/**
|
||||
* Subclass of LibraryItem that emulates a Book item in a Library
|
||||
*
|
||||
* @George Wilkinson
|
||||
* @1.0
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.ArrayList;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class Book extends LibraryItem
|
||||
{
|
||||
private String author;
|
||||
private String isbn;
|
||||
|
||||
/**
|
||||
* Constructor for objects of class Book
|
||||
*/
|
||||
public Book(){}
|
||||
|
||||
public void printDetails() {
|
||||
System.out.println("\n==================\n( " + getItemCode() + " )" + " ISBN: " + isbn + " Book " + getTitle() + ", written by " + author + ", published by " + getPublisher() + " has " + getNoOfPages() + " pages .\nIt has been borrowed " + getTimesBorrowed() + " times.");
|
||||
if( getOnLoan() )
|
||||
System.out.println( "The Book is currently on loan, and costs " + getCost() + " pence. ");
|
||||
else
|
||||
System.out.println( "The Book is currently not on loan, and costs " + getCost() + " pence. ");
|
||||
}
|
||||
|
||||
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