vault backup: 2024-03-05 16:01:50

This commit is contained in:
2024-03-05 16:01:50 +00:00
parent 8ce640b4ba
commit 28ea6a0a9b
36 changed files with 314 additions and 89 deletions

View File

@@ -3,7 +3,7 @@
* Superclass of items / assets stored in a Library.
*
* @George Wilkinson
* @2.1
* @3.1
*/
import java.util.Scanner;
@@ -12,7 +12,7 @@ import java.util.NoSuchElementException;
public abstract class LibraryItem
{
// instance variables - replace the example below with your own
// instance variables
private String title;
private String itemCode;
private int cost;
@@ -81,25 +81,15 @@ public abstract class LibraryItem
/*
* 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.");
if( onLoan )
System.out.println( "This item is at present on loan and when new cost " + cost + " pence.\n" );
else
System.out.println( "This item is at present not on loan and when new cost " + cost + " pence.\n" );
}
/*
* Print to terminal, relevant field variables
*/
public void printDetails()
{
System.out.println("Item Code: " + itemCode +
"\nTitle: " + title +
"\nCost: £" + ( ( float )( cost ) )/100 +
"\nCost: £" + ( ( float )( cost ) )/100 + // Convert cost in pence to £pounds.pence to be more readable.
"\nBorrowed " + getTimesBorrowed() + " times." );
if( getOnLoan() )
System.out.println( "On Loan");
@@ -107,6 +97,9 @@ public abstract class LibraryItem
System.out.println( "Available to Loan");
}
/*
* Passed a scanner object, assign values to relevant field variables
*/
public void readItemData( Scanner detailScanner ) {
if ( detailScanner != null ) {