⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 borroweditems.java

📁 ssd3的教程 是我们老师给我们的 纯英文 有兴趣的可以
💻 JAVA
字号:
import java.util.*;
import java.text.*;

/**
 * Maintains a collection of {@link CatalogItems}
 * assigned to a borrower.
 *
 * @author author name
 * @version  1.0.0
 * @see CatalogItem
 */
public class BorrowedItems {


    /* Catalog items assigned to a borrower.*/
    private Vector  items;

    /**
     * Sets the collection of {@link CatalogItems} to empty.
     */
    public BorrowedItems()  {

        items = new Vector();
    }

    /**
     * Adds a {@link CatalogItem} object to this collection and
     * sets the {@link CatalogItem} object as not available.
     *
     * @param item  the {@link CatalogItem} object.
     */
    public void  addItem(CatalogItem catalogItem)  {

        items.add(catalogItem);
        catalogItem.setAvailable(false);
    }

    /**
     * Removes a {@link CatalogItem} object from this collection
     * and sets the {@link CatalogItem} object as available.
     *
     * @param item  the {@link CatalogItem} object.
     */
    public void  removeItem(CatalogItem catalogItem)  {

        items.removeElement(catalogItem);
        catalogItem.setAvailable(true);
    }

    /**
     * Returns an iterator over the borrowed items in this
     * collection.
     *
     * return  an {@link Iterator}
     */
    public Iterator  getItemsIterator() {

        return items.iterator();
    }

    /**
     * Returns the {@link CatalogItem} object with the specified
     * <code>code</code>. 
     *
     * @param code  the code of an item.
     * @return  The {@link CatalogItem} object with the specifed
     *          code. Returns <code>null</code> if the object with
     *          the code is not found.
     */
    public CatalogItem  getItem(String code)  {

        for (Iterator i = getItemsIterator(); i.hasNext();) {

            CatalogItem catalogItem = (CatalogItem) i.next();

            if (catalogItem.getCode().equals(code)) {

                return catalogItem;
            }
        }

        return null;
    }

    /**
     * Returns the number of borrowed items.
     *
     * @return  the number of borrowed items.
     */
    public int  getNumberOfItems()  {

        return items.size();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -