PPT Slide
public Book(String t, String a, String i, PostScript p) {
public UserID get_borrower() {return borrower;}
public void set_borrower(UserID u) {borrower = u;}
public PostScript get_ps() { return ps; }
public BookID get_bid() { return id; }
public BookID(String t, String a, String i) {
public String get_title() {return title;}
public User(String n) { id = new UserID(n); }
public boolean getBook (String title) {
aBook = theLibrary.getBook(id, title);
} catch (RemoteException e) {}
thePrinter.print(id, aBook);
} catch (RemoteException e) {}
public UserID get_uid() { return id; }
public UserID(String n) { name = n; }
public String get_name() { return name; }
interface LibraryInterface extends Remote {
public BookID getBook(UserID u, String title) throws RemoteException;
public PostScript getBookPS(BookID bid) throws RemoteException;
class Library extends UnicastRemoteObject implements LibraryInterface {
Library() throws RemoteException {
books = new Hashtable(100);
public BookID getBook(UserID u, String title)
System.out.println("REQUEST TO GET BOOK " + title);
if(books.containsKey(title)) {
Book b = (Book)books.get(title);
System.out.println("getBook: Found it:" + b);
if (b.get_borrower() == null) {
public PostScript getBookPS(BookID bid)
if (books.containsKey(bid.get_title())) {
Book b = (Book)books.get(bid.get_title());
interface PrinterInterface extends Remote {
public boolean print (UserID u, BookID b) throws RemoteException;
class Printer extends UnicastRemoteObject
implements PrinterInterface {
private Library theLibrary;
public Printer() throws RemoteException{}
public boolean print (UserID u, BookID b) throws RemoteException{
try{ps = theLibrary.getBookPS(b);}
catch (RemoteException e) {}
Job newJob = new Job (ps, u.get_name());