Initial Commit P2 Part 1
This commit is contained in:
103
Semester 2/Programming 2/Project/Part 1/LibraryItem.java
Normal file
103
Semester 2/Programming 2/Project/Part 1/LibraryItem.java
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
/**
|
||||
* 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." );
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user