home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / ODesign / SetupPSE.exe / data.z / Account.java < prev    next >
Encoding:
Java Source  |  1997-01-24  |  2.1 KB  |  96 lines

  1. package COM.odi.demo.threads;
  2.  
  3. /**
  4.  *      <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
  5.  * Account represents information of individual Account in the bank.
  6.  */
  7.  
  8. import COM.odi.*;
  9.  
  10. public class Account {
  11.   /* Account holders name */
  12.  
  13.   private String name;
  14.  
  15.   /* Account holders age. */
  16.   private int age;
  17.  
  18.   /* Account Holders Social security number */
  19.  
  20.   private String ssn;
  21.  
  22.   /* Type of account Checking/Savings */
  23.  
  24.   private String actType;
  25.  
  26.   /* Balance Amount in the Account */
  27.  
  28.   private float balAmount;
  29.  
  30.   /* since we dont want this to be stored in hash table we overload
  31.      hashCode and call super.hashCode() 
  32.   */    
  33.   public int hashCode() {
  34.     return super.hashCode();
  35.   }
  36.  
  37.   /**
  38.    * initialize individual Account.This is called at the time of creation of
  39.    * a new Account.
  40.    * @name name of Account holder.
  41.    * @age Age of account holder.
  42.    * @ssn Social Security number of Account holder.
  43.    * @actType Type of Account.
  44.    * @balAmount Initial Amount for Account holder.
  45.    */
  46.    public Account(String name, int age, String ssn, String actType, float balAmount) {
  47.     this.name = name;
  48.     this.age = age;
  49.     this.ssn = ssn;
  50.     this.actType = actType;
  51.     this.balAmount = balAmount;
  52.   }
  53.  
  54.   /**
  55.    * checks if Account Holders SSN is same as what we want
  56.    * @ssn Account holders social security number.
  57.    */
  58.   public boolean isSSN(String ssn) {
  59.     if (this.ssn.compareTo(ssn) == 0)
  60.       return true;
  61.     else
  62.       return false;
  63.   }
  64.  
  65.   /**
  66.    * deposit amount in the account.
  67.    */
  68.   public void deposit(float amount) {
  69.     balAmount += amount;
  70.   }
  71.  
  72.   /**
  73.    * Withdraw amount from the account.
  74.    */
  75.   public void withDraw(float amount) {
  76.     balAmount -= amount;
  77.   }
  78.  
  79.   public int getAge() {
  80.     return this.age;
  81.   }
  82.      
  83.   public float getBalAmount() {
  84.     return this.balAmount;
  85.   }
  86.  
  87.   public void displayAccountInfo(String threadName) {
  88.     System.out.println(threadName + " Name :" + name);
  89.     System.out.println(threadName + " AGE :" + age);
  90.     System.out.println(threadName + " SSN :" + ssn);
  91.     System.out.println(threadName + " Account Type :" + actType);
  92.     System.out.println(threadName + " Balance :" + balAmount);
  93.   }
  94.  
  95. };
  96.