package dbj.odmg; import COM.POET.odmg.collection.*; import java.util.Enumeration; public class Book { String isbn_; String title_; double price_; Publisher publisher_; Category category_; VArrayOfObject authors_; int stock_; public Book (String isbn) { isbn_ = isbn; authors_ = new VArrayOfObject (); } public void setPrice (double p) { price_ = p; } public void setTitle (String s) { title_ = s; } public void setPublisher (Publisher p) { publisher_ = p; } public void addAuthor (Author a) { authors_.add (a); } public void setCategory (Category c) { category_ = c; } public void setStock (int num) { stock_ = num; } public double getPrice () { return price_; } public int getStock () { return stock_; } public boolean reduceStock (int num) { if (stock_ > num) { stock_ -= num; return true; } else return false; } public String toString () { StringBuffer buf = new StringBuffer (); Enumeration e = authors_.elements (); int i = 0, num = authors_.size (); while (e.hasMoreElements ()) { Author a = (Author) e.nextElement (); buf.append (a.toString ()); if (++i < num) buf.append (", "); } buf.append (": " + title_ + "; " + isbn_ + "; " + price_ + " [" + stock_ + "]"); return buf.toString (); } }