vault backup: 2024-03-05 13:01:43
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
|
||||
/**
|
||||
* Emulates an Item in a Library (
|
||||
* Superclass of items / assets stored in a Library.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
* @George Wilkinson
|
||||
* @2.1
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
@@ -18,8 +18,6 @@ public abstract class LibraryItem
|
||||
private int cost;
|
||||
private int timesBorrowed;
|
||||
private boolean onLoan;
|
||||
private int noOfPages;
|
||||
private String publisher;
|
||||
|
||||
/*
|
||||
* Field Accessor Start
|
||||
@@ -48,17 +46,7 @@ public abstract class LibraryItem
|
||||
{
|
||||
return onLoan;
|
||||
}
|
||||
|
||||
public int getNoOfPages()
|
||||
{
|
||||
return noOfPages;
|
||||
}
|
||||
|
||||
public String getPublisher()
|
||||
{
|
||||
return publisher;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Field Accessor End
|
||||
*
|
||||
@@ -90,21 +78,13 @@ public abstract class LibraryItem
|
||||
this.onLoan = onLoan;
|
||||
}
|
||||
|
||||
public void setNoOfPages( int noOfPages )
|
||||
{
|
||||
this.noOfPages = noOfPages;
|
||||
}
|
||||
|
||||
public void setPublisher( String publisher )
|
||||
{
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Mutator End
|
||||
*/
|
||||
|
||||
// Output to console the details of the fields in a human-readable format.
|
||||
|
||||
/*
|
||||
public void printDetails()
|
||||
{
|
||||
System.out.println( title + " with an item code " + itemCode + " has been borrowed " + timesBorrowed + " times.");
|
||||
@@ -113,12 +93,23 @@ public abstract class LibraryItem
|
||||
else
|
||||
System.out.println( "This item is at present not on loan and when new cost " + cost + " pence.\n" );
|
||||
}
|
||||
*/
|
||||
|
||||
public void readItemData( Scanner detailScanner ) {
|
||||
public void printDetails()
|
||||
{
|
||||
System.out.println("Item Code: " + itemCode +
|
||||
"\nTitle: " + title +
|
||||
"\nCost: £" + ( ( float )( cost ) )/100 +
|
||||
"\nBorrowed " + getTimesBorrowed() + " times." );
|
||||
if( getOnLoan() )
|
||||
System.out.println( "On Loan");
|
||||
else
|
||||
System.out.println( "Available to Loan");
|
||||
}
|
||||
|
||||
public void readItemData( Scanner detailScanner ) {
|
||||
|
||||
if ( detailScanner != null ) {
|
||||
this.noOfPages = Integer.parseInt( detailScanner.next().trim() );
|
||||
this.publisher = detailScanner.next().trim();
|
||||
this.title = detailScanner.next().trim();
|
||||
this.itemCode = detailScanner.next().trim();
|
||||
this.cost = Integer.parseInt( detailScanner.next().trim() );
|
||||
|
Reference in New Issue
Block a user