/** * Representation of common properties of items in a library's circulation system * (Version 1, no abstract classes/methods) * CSE142 lecture example 3/03 HP * * Note: to keep the example simple, there is no attempt to detect problems like * trying to check in an item that is not checked out, etc. */ public class CirculationItem { // instance variables private String title; // item title private String callNumber; // Library of Congress call # private boolean checkedOut; // = "this item is currently checked out" /** Construct new CirculationItem with specified title and call # */ public CirculationItem(String title, String callNumber) { this.title = title; this.callNumber = callNumber; this.checkedOut = false; } /** Return the title of this CirculationItem */ public String getTitle() { return title; } /** Return the call number of this CirculationItem */ public String getCallNumber() { return callNumber; } /** Check in this CirculationItem */ public void checkin() { checkedOut = false; } /** Check out this CirculationItem */ public void checkout() { checkedOut = true; } /** = "this item is in the library" */ public boolean inLibrary() { return !checkedOut; } public String toString() { return "CirculationItem(title=" + title + ", callNumber=" + callNumber + "checked out=" + checkedOut + ")"; } }