vault backup: 2024-04-12 09:39:31
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
|
||||
/**
|
||||
* Subclass of LibraryItem to create objects of printed items in a library.
|
||||
*
|
||||
* @George Wilkinson
|
||||
* @1.1
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public abstract class PrintedItem extends LibraryItem
|
||||
{
|
||||
private int noOfPages;
|
||||
private String publisher;
|
||||
|
||||
/*
|
||||
* Field Accessor Start
|
||||
*/
|
||||
public int getNoOfPages()
|
||||
{
|
||||
return noOfPages;
|
||||
}
|
||||
|
||||
public String getPublisher()
|
||||
{
|
||||
return publisher;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Accessor End
|
||||
*
|
||||
* Field Mutator Start
|
||||
*/
|
||||
|
||||
public void setNoOfPages( int noOfPages )
|
||||
{
|
||||
this.noOfPages = noOfPages;
|
||||
}
|
||||
|
||||
public void setPublisher( String publisher )
|
||||
{
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Mutator End
|
||||
*/
|
||||
public void printDetails()
|
||||
{
|
||||
System.out.println("Page Count: " + noOfPages +
|
||||
"\nPublisher: " + publisher);
|
||||
super.printDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the fields with details from the scanner
|
||||
* Takes Parameters
|
||||
* Scanner @detailScanner
|
||||
*/
|
||||
public void readItemData( Scanner detailScanner ){
|
||||
if ( detailScanner != null ) {
|
||||
this.noOfPages = Integer.parseInt( detailScanner.next().trim() );
|
||||
this.publisher = detailScanner.next().trim();
|
||||
super.readItemData( detailScanner );
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user