home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-01-24 | 2.1 KB | 96 lines |
- package COM.odi.demo.threads;
-
- /**
- * <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
- * Account represents information of individual Account in the bank.
- */
-
- import COM.odi.*;
-
- public class Account {
- /* Account holders name */
-
- private String name;
-
- /* Account holders age. */
- private int age;
-
- /* Account Holders Social security number */
-
- private String ssn;
-
- /* Type of account Checking/Savings */
-
- private String actType;
-
- /* Balance Amount in the Account */
-
- private float balAmount;
-
- /* since we dont want this to be stored in hash table we overload
- hashCode and call super.hashCode()
- */
- public int hashCode() {
- return super.hashCode();
- }
-
- /**
- * initialize individual Account.This is called at the time of creation of
- * a new Account.
- * @name name of Account holder.
- * @age Age of account holder.
- * @ssn Social Security number of Account holder.
- * @actType Type of Account.
- * @balAmount Initial Amount for Account holder.
- */
- public Account(String name, int age, String ssn, String actType, float balAmount) {
- this.name = name;
- this.age = age;
- this.ssn = ssn;
- this.actType = actType;
- this.balAmount = balAmount;
- }
-
- /**
- * checks if Account Holders SSN is same as what we want
- * @ssn Account holders social security number.
- */
- public boolean isSSN(String ssn) {
- if (this.ssn.compareTo(ssn) == 0)
- return true;
- else
- return false;
- }
-
- /**
- * deposit amount in the account.
- */
- public void deposit(float amount) {
- balAmount += amount;
- }
-
- /**
- * Withdraw amount from the account.
- */
- public void withDraw(float amount) {
- balAmount -= amount;
- }
-
- public int getAge() {
- return this.age;
- }
-
- public float getBalAmount() {
- return this.balAmount;
- }
-
- public void displayAccountInfo(String threadName) {
- System.out.println(threadName + " Name :" + name);
- System.out.println(threadName + " AGE :" + age);
- System.out.println(threadName + " SSN :" + ssn);
- System.out.println(threadName + " Account Type :" + actType);
- System.out.println(threadName + " Balance :" + balAmount);
- }
-
- };
-