Source of AccountRecord.java


  1: // Fig. 14.5: AccountRecord.java
  2: // A class that represents one record of information.
  3: package com.deitel.jhtp6.ch14; // packaged for reuse
  4: 
  5: public class AccountRecord
  6: {
  7:    private int account;
  8:    private String firstName;
  9:    private String lastName;
 10:    private double balance;
 11:    
 12:    // no-argument constructor calls other constructor with default values
 13:    public AccountRecord() 
 14:    {
 15:       this( 0, "", "", 0.0 ); // call four-argument constructor
 16:    } // end no-argument AccountRecord constructor
 17:   
 18:    // initialize a record
 19:    public AccountRecord( int acct, String first, String last, double bal )
 20:    {
 21:       setAccount( acct );
 22:       setFirstName( first );
 23:       setLastName( last );
 24:       setBalance( bal );
 25:    } // end four-argument AccountRecord constructor
 26: 
 27:    // set account number   
 28:    public void setAccount( int acct )
 29:    {
 30:       account = acct;
 31:    } // end method setAccount
 32: 
 33:    // get account number   
 34:    public int getAccount() 
 35:    { 
 36:       return account; 
 37:    } // end method getAccount
 38:    
 39:    // set first name   
 40:    public void setFirstName( String first )
 41:    {
 42:       firstName = first;
 43:    } // end method setFirstName
 44: 
 45:    // get first name   
 46:    public String getFirstName() 
 47:    { 
 48:       return firstName; 
 49:    } // end method getFirstName
 50:    
 51:    // set last name   
 52:    public void setLastName( String last )
 53:    {
 54:       lastName = last;
 55:    } // end method setLastName
 56: 
 57:    // get last name   
 58:    public String getLastName() 
 59:    {
 60:       return lastName; 
 61:    } // end method getLastName
 62:    
 63:    // set balance  
 64:    public void setBalance( double bal )
 65:    {
 66:       balance = bal;
 67:    } // end method setBalance
 68: 
 69:    // get balance   
 70:    public double getBalance() 
 71:    { 
 72:       return balance; 
 73:    } // end method getBalance
 74: } // end class AccountRecord
 75: 
 76: /*************************************************************************
 77: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 78: * Pearson Education, Inc. All Rights Reserved.                           *
 79: *                                                                        *
 80: * DISCLAIMER: The authors and publisher of this book have used their     *
 81: * best efforts in preparing the book. These efforts include the          *
 82: * development, research, and testing of the theories and programs        *
 83: * to determine their effectiveness. The authors and publisher make       *
 84: * no warranty of any kind, expressed or implied, with regard to these    *
 85: * programs or to the documentation contained in these books. The authors *
 86: * and publisher shall not be liable in any event for incidental or       *
 87: * consequential damages in connection with, or arising out of, the       *
 88: * furnishing, performance, or use of these programs.                     *
 89: *************************************************************************/