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

📄 borrowerinformation.java

📁 数据结构及算法 对于参加ACM的学生有一定帮助 里面有详细的解答
💻 JAVA
字号:
//
//  Unified Library Application
//  Case study in Unified Modeling Language Toolkit
//
//  BorrowerInformation.java: information about a borrower.
//  A borrower can be a person or another library. A borrower
//  can have loans and reservations.
//
//  Copyright (c) 1998 John Wiley & Sons, Inc. All rights reserved.
//  Reproduction or translations of this work beyond that permitted
//  in Section 117 of the 1976 United States Copyright Act without
//  the express written permission of the copyright owner is unlawful.
//  Requests for further information should be addressed to Permissions
//  Department, John Wiley & Sons, Inc. The purchaser may make back-up
//  copies for his/her own use only and not for distribution or resale.
//  The Publisher assumes no responsibility for errors, omissions, or
//  damages, caused by the use of these programs of from the use of the
//  information contained herein.

package bo;
import util.ObjId;
import db.*;
import java.io.*;
import java.util.*;
public class BorrowerInformation extends Persistent
{
    private String lastname;
    private String firstname;
    private String address;
    private String city;
    private String zip;
    private String state;
    private Vector loans = new Vector();
    private Vector reservations = new Vector();
    public BorrowerInformation()
    {
    }
    public BorrowerInformation(String ln, String fn, String a, String c, String z, String s)
    {
        lastname = ln;
        firstname = fn;
        address = a;
        city = c;
        zip = z;
        state = s;
    }
    public static BorrowerInformation getBorrowerInformation(ObjId id)
    {
        return (BorrowerInformation) Persistent.getObject(id);
    }
        public static BorrowerInformation findOnLastName(String lastname)
    {
        BorrowerInformation i = (BorrowerInformation) iterate("bo.BorrowerInformation",true);
        while (i != null)
        {
            if (i.getLastName().toUpperCase().equals(lastname.toUpperCase()))
            {
                return i;
            }
            else
                i = (BorrowerInformation) iterate("bo.BorrowerInformation",false);
        }
        return null;
    }
    public static BorrowerInformation iterateBorrower(boolean init)
    {
        return (BorrowerInformation) iterate("bo.BorrowerInformation",init);
    }
    public String getLastName() { return lastname; }
    public String getFirstName() { return firstname; }
    public String getAddress() { return address; }
    public String getCity() { return city; }
    public String getZip() { return zip; }
    public String getState() { return state; }
    public void setLastName(String ln) { lastname = ln; }
    public void setFirstName(String fn) { firstname = fn; }
    public void setAddress(String a) { address = a; }
    public void setCity(String c) { city = c; }
    public void setZip(String z) { zip = z; }
    public void setState(String s) { state = s; }
    public void addLoan(ObjId loan)
    {
        loans.addElement(loan);
    }
    public void removeLoan(ObjId loan)
    {
        loans.removeElement(loan);
    }
    public Loan getLoan(int index)
    {
        if (index < loans.size())
        {
            ObjId id = (ObjId) loans.elementAt(index);
            return (Loan) Persistent.getObject(id);
        }
        else
            return null;
    }
    public int getNoLoans()
    {
        return loans.size();
    }
    public void addReservation(ObjId reservation)
    {
        reservations.addElement(reservation);
    }
    public void removeReservation(ObjId reservation)
    {
        reservations.removeElement(reservation);
    }
    public Reservation getReservation(int index)
    {
        if (index < reservations.size())
        {
            ObjId id = (ObjId) reservations.elementAt(index);
            return (Reservation) Persistent.getObject(id);
        }
        else
            return null;
    }
    public int getNoReservations()
    {
        return reservations.size();
    }
    public void write(RandomAccessFile out)
        throws IOException
    {
        out.writeUTF(lastname);
        out.writeUTF(firstname);
        out.writeUTF(address);
        out.writeUTF(city);
        out.writeUTF(zip);
        out.writeUTF(state);
        out.writeInt(loans.size());
        for (int i = 0; i < loans.size(); i++)
        {
            ObjId id = (ObjId) loans.elementAt(i);
            id.write(out);
        }
        out.writeInt(reservations.size());
        for (int i = 0; i < reservations.size(); i++)
        {
            ObjId id = (ObjId) reservations.elementAt(i);
            id.write(out);
        }
    }
    public void read(RandomAccessFile in)
        throws IOException
    {
        lastname = in.readUTF();
        firstname = in.readUTF();
        address = in.readUTF();
        city = in.readUTF();
        zip = in.readUTF();
        state = in.readUTF();
        int nrLoans = in.readInt();
        loans.removeAllElements();
        for (int i = 0; i < nrLoans; i++)
        {
            ObjId id = new ObjId();
            id.read(in);
            loans.addElement(id);
        }
        int nrReservations = in.readInt();
        reservations.removeAllElements();
        for (int i = 0; i < nrReservations; i++)
        {
            ObjId id = new ObjId();
            id.read(in);
            reservations.addElement(id);
        }
    }

}

⌨️ 快捷键说明

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