vault backup: 2024-02-06 13:09:16
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LibraryItem
|
||||
{
|
||||
// instance variables - replace the example below with your own
|
||||
@@ -26,6 +30,18 @@ public class LibraryItem
|
||||
this.onLoan = onLoan;
|
||||
}
|
||||
|
||||
/*
|
||||
* Default constructor for object of class LibraryItem
|
||||
*/
|
||||
public LibraryItem()
|
||||
{
|
||||
title = "";
|
||||
itemCode = "";
|
||||
cost = 0;
|
||||
timesBorrowed = 0;
|
||||
onLoan = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Field Accessor Start
|
||||
*/
|
||||
@@ -94,10 +110,16 @@ public class LibraryItem
|
||||
{
|
||||
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." );
|
||||
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." );
|
||||
System.out.println( "This item is at present not on loan and when new cost " + cost + " pence.\n" );
|
||||
}
|
||||
|
||||
|
||||
public void readData( Scanner detailScanner ) {
|
||||
this.title = detailScanner.next();
|
||||
this.itemCode = detailScanner.next();
|
||||
this.cost = Integer.parseInt( detailScanner.next() );
|
||||
this.timesBorrowed = Integer.parseInt( detailScanner.next() );
|
||||
this.onLoan = Boolean.parseBoolean( detailScanner.next() );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user