how to compare two bank accounts: do the accounts have the same amount of money

Feb 21 2010 2:31 PM
hello

i need help on comparing two bank accounts and finding out if the accounts have the more less or equals amounts of money in them. i am truly lost, my teacher went to fast in class and im not sure where i can find this information out
  public class AccountC
    {
        //Data declarations
         protected string accountName;
         protected double accountBalance;
         protected double transactionAmount;
         protected char transactionType;
         protected static double penalty = 40.0;
         //constructors
         public AccountC()
        {
             this.accountName ="";
             this.accountBalance = 0.0;
             this.transactionAmount =0.0;
             this.transactionType = ' ';

        }
         // constructor
         public AccountC (string an, double ab, double ta, char tt)
         {
             this.AccountNumber = an;
             this.accountBalance = ab;
             this.transactionAmount = ta;
             this.transactionType = tt;
         }
             // properties

         public String AccountNumber
         {
             get{return this.AccountNumber;}
             set{ this.AccountNumber = value;}
         }
         public double Balance
         {
             get{return this.accountBalance;}
             set{this.accountBalance = value;}
         }
         public double TransActionAmount
         {
             get{ return this.transactionAmount;}
             set{this.transactionAmount = value;}
         }
         public char TransactionType
         {
             get{ return this.TransactionType;}
             set{this.transactionType = value;}
         }
         //processing methods
         //process tranactiontransaction
    
        public double Tranaction()
        {
            if(this.transactionType =='w'|| this.transactionType =='W')
                if(this.accountBalance>= this.TransActionAmount)
                    this.accountBalance= this.accountBalance - this.TransActionAmount;
            else
                {
         this.accountBalance=this.accountBalance - AccountC.penalty;
                    console.WriteLine("\n\tInsufficient funds.A penalty appplied\n\tCurrent balnce= "+ this.Balance);
                }
            else if(this.transactionAmount == 'd'|| this.transactionType =='D')
            {
                this.accountBalance = this.accountBalance + this.transactionAmount;
                console.WriteLine(this.transactionAmount + "\tadded to current balance");
            }
            else Console.WriteLine("Bad transaction code, balance was not chaned\n");
            return this.accountBalance;
        }
         //compare two accounts; used for sorting and searching
         public int CompareTo(AccountC account) // a reference of type object can refer to any object type
         {
             return this.accountNumber.CompareTo(account.AccountNumber);
         }
             //used for outputing an account data members
             public override string ToString()
             {
                 return this.accountName.ToString() + '\n'
                     + this.accountBalance.ToString() + '\n'
                     + this.transactionAmount.ToString() + '\n'
                     + this.transactionType.ToString() + '\n';

    }



Answers (3)