104 lines
2.2 KiB
Java
104 lines
2.2 KiB
Java
|
|
/**
|
|
* Write a description of class LibraryItem here.
|
|
*
|
|
* @author (your name)
|
|
* @version (a version number or a date)
|
|
*/
|
|
public class LibraryItem
|
|
{
|
|
// instance variables - replace the example below with your own
|
|
private String title;
|
|
private String itemCode;
|
|
private int cost;
|
|
private int timesBorrowed;
|
|
private boolean onLoan;
|
|
|
|
/**
|
|
* Constructor for objects of class LibraryItem
|
|
*/
|
|
public LibraryItem( String title, String itemCode, int cost, int timesBorrowed, boolean onLoan)
|
|
{
|
|
this.title = title;
|
|
this.itemCode = itemCode;
|
|
this.cost = cost;
|
|
this.timesBorrowed = timesBorrowed;
|
|
this.onLoan = onLoan;
|
|
}
|
|
|
|
/*
|
|
* Field Accessor Start
|
|
*/
|
|
public String getTitle()
|
|
{
|
|
return title;
|
|
}
|
|
|
|
public String getItemCode()
|
|
{
|
|
return itemCode;
|
|
}
|
|
|
|
public int getCost()
|
|
{
|
|
return cost;
|
|
}
|
|
|
|
public int getTimesBorrowed()
|
|
{
|
|
return timesBorrowed;
|
|
}
|
|
|
|
public boolean getOnLoan()
|
|
{
|
|
return onLoan;
|
|
}
|
|
|
|
/*
|
|
* Field Accessor End
|
|
*
|
|
* Field Mutator Start
|
|
*/
|
|
|
|
public void setTitle( String title )
|
|
{
|
|
this.title = title;
|
|
}
|
|
|
|
public void setItemCode( String itemCode )
|
|
{
|
|
this.itemCode = itemCode;
|
|
}
|
|
|
|
public void setCost( int cost )
|
|
{
|
|
this.cost = cost;
|
|
}
|
|
|
|
public void setTimesBorrowed( int timesBorrowed )
|
|
{
|
|
this.timesBorrowed = timesBorrowed;
|
|
}
|
|
|
|
public void setOnLoan( boolean onLoan )
|
|
{
|
|
this.onLoan = onLoan;
|
|
}
|
|
|
|
/*
|
|
* 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." );
|
|
else
|
|
System.out.println( "This item is at present not on loan and when new cost " + cost + " pence." );
|
|
}
|
|
|
|
|
|
}
|