| | |
Bank Assignment
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
Here are my parameters to follow: Every Account at the bank keeps track of a balance. In addition, each Account allows users to deposit and withdraw money. Accounts are subdivided into:
SavingsAccount. This type of account has an interest rate associated with it. This rate is used at the end of each month to calculate the amount of interest earned on the account.
CheckingAccount. This type of account does not earn any interest and therefore does not have an interest rate associated with it. Additionally, when account holders perform any type of transaction, there is a fee involved.
Be sure to set up your classes as follows:
Class Account should contain one private data member to store the account balance. It should also have two constructors – one that takes a value representing the starting balance, a second that accepts no values and sets the balance to zero. This class should also provide methods to allow the user to add money to the account (Credit) and take money out of the account (Debit). Be sure that you have validation in place so that the balance is never less than zero. Finally, be sure to provide an accessor method for the balance variable to return the account balance.
Class SavingsAccount should inherit from Account, but also needs to keep track of the interest rate in a private variable. Be sure to provide 2 constructors for this account as well: one that accepts a balance and an interest rate and one that accepts only an interest rate (the balance should then be set to zero). Finally, add a method in this class that will return the amount of interest gained (CalculateInterest). This method will not require any parameters and will simply return the interest based on the current balance multiplied by the interest rate.
Class CheckingAccount should also inherit from Account. However, this class needs to keep track of a transaction fee. This class should have two constructors – one that takes the balance and the transaction fee and another that takes the transaction fee only (and sets the balance to zero). This class will need to redefine Debit and Credit so that the transaction fee is deducted from the balance each time. Be sure that you are calling on the Credit and Debit methods in the Account class appropriately. Also note that if there are not enough funds to debit the money and the transaction fee, then no transaction should take place.
Once you have all three classes working, write a GUI application that allows the user to create one checking and one savings account. Your program should allow the user to work with the accounts and attempt any transactions they wish. Note that for this exercise, you can assume an intelligent user. That is, if the user is expected to enter a number, you can assume that a number will be entered and not a word.
I'm getting use of unassigned variable. I can get around it by dropping AccountChecking checkingAccount = new AccountChecking or Savings in various parts of the code. But I know I should not have to call the same checkingAccount or Savings that often. I included the whole project in a zip also.
SavingsAccount. This type of account has an interest rate associated with it. This rate is used at the end of each month to calculate the amount of interest earned on the account.
CheckingAccount. This type of account does not earn any interest and therefore does not have an interest rate associated with it. Additionally, when account holders perform any type of transaction, there is a fee involved.
Be sure to set up your classes as follows:
Class Account should contain one private data member to store the account balance. It should also have two constructors – one that takes a value representing the starting balance, a second that accepts no values and sets the balance to zero. This class should also provide methods to allow the user to add money to the account (Credit) and take money out of the account (Debit). Be sure that you have validation in place so that the balance is never less than zero. Finally, be sure to provide an accessor method for the balance variable to return the account balance.
Class SavingsAccount should inherit from Account, but also needs to keep track of the interest rate in a private variable. Be sure to provide 2 constructors for this account as well: one that accepts a balance and an interest rate and one that accepts only an interest rate (the balance should then be set to zero). Finally, add a method in this class that will return the amount of interest gained (CalculateInterest). This method will not require any parameters and will simply return the interest based on the current balance multiplied by the interest rate.
Class CheckingAccount should also inherit from Account. However, this class needs to keep track of a transaction fee. This class should have two constructors – one that takes the balance and the transaction fee and another that takes the transaction fee only (and sets the balance to zero). This class will need to redefine Debit and Credit so that the transaction fee is deducted from the balance each time. Be sure that you are calling on the Credit and Debit methods in the Account class appropriately. Also note that if there are not enough funds to debit the money and the transaction fee, then no transaction should take place.
Once you have all three classes working, write a GUI application that allows the user to create one checking and one savings account. Your program should allow the user to work with the accounts and attempt any transactions they wish. Note that for this exercise, you can assume an intelligent user. That is, if the user is expected to enter a number, you can assume that a number will be entered and not a word.
I'm getting use of unassigned variable. I can get around it by dropping AccountChecking checkingAccount = new AccountChecking or Savings in various parts of the code. But I know I should not have to call the same checkingAccount or Savings that often. I included the whole project in a zip also.
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace _0804A_IT466_DavidSchmidtII_Unit4_Bank_Account { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public int caseNumber = 0; public double chckFee = .50; public double interestRate = .03; public double interestBalance; public double retrieveBalance; private void openSavBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = false; closeSavBtn.Visible = true; openSavBtn.Visible = false; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 1; } private void closeSavBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; closeSavBtn.Visible = false; openSavBtn.Visible = true; savDepositBtn.Visible = false; savWithdrawlBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 0; } private void openChckBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = false; closeChckBtn.Visible = true; openChckBtn.Visible = false; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 2; AccountChecking checkingAccount = new AccountChecking(0, chckFee); } private void closeChckBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; closeChckBtn.Visible = false; openChckBtn.Visible = true; chckDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; caseNumber = 0; AccountChecking checkingAccount = new AccountChecking(0); } private void chckDepositBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 3; } private void chckWithdrawlBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = true; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 5; } private void savDepositBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 4; } private void savWithdrawlBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = true; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 6; } private void doneBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; if (openChckBtn.Visible == false) { chckDepositBtn.Visible = true; chckWithdrawlBtn.Visible = true; chckBalanceBtn.Visible = true; } if (openSavBtn.Visible == false) { savBalanceBtn.Visible = true; savWithdrawlBtn.Visible = true; savDepositBtn.Visible = true; savInterestBtn.Visible = true; } switch (caseNumber) { case 1: AccountSavings savingsAccount = new AccountSavings(Convert.ToDouble(amountTxtBx.Text), interestRate); amountTxtBx.Text = ""; break; case 2: AccountChecking checkingAccount = new AccountChecking(Convert.ToDouble(amountTxtBx.Text), chckFee); amountTxtBx.Text = ""; break; case 3: checkingAccount.credit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 4: savingsAccount.credit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 5: checkingAccount.debit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 6: savingsAccount.debit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; default: amountTxtBx.Text = ""; break; } } private void cancelBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; if (openChckBtn.Visible == false) { chckDepositBtn.Visible = true; chckWithdrawlBtn.Visible = true; chckBalanceBtn.Visible = true; } if (openSavBtn.Visible == false) { savBalanceBtn.Visible = true; savWithdrawlBtn.Visible = true; savDepositBtn.Visible = true; savInterestBtn.Visible = true; } amountTxtBx.Text = " "; } private void chckBalanceBtn_Click(object sender, EventArgs e) { amountTxtBx.Visible = true; doneBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 0; retrieveBalance = checkingAccount.balanceInquery; amountTxtBx.Text = Convert.ToString(retrieveBalance); } private void savBalanceBtn_Click(object sender, EventArgs e) { amountTxtBx.Visible = true; doneBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 0; retrieveBalance = savingsAccount.balanceInquery; amountTxtBx.Text = Convert.ToString(retrieveBalance); } private void savInterestBtn_Click(object sender, EventArgs e) { amountTxtBx.Visible = true; doneBtn.Visible = true; interestBalance = savingsAccount.calcInterest(); amountTxtBx.Text = Convert.ToString(interestBalance); } private void chckDoneBtn_Click(object sender, EventArgs e) { AccountChecking checkingAccount = new AccountChecking(Convert.ToDouble(amountTxtBx.Text), chckFee); } private void savDoneBtn_Click(object sender, EventArgs e) { AccountChecking checkingAccount = new AccountChecking(Convert.ToDouble(amountTxtBx.Text), chckFee); } } }
Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways - Chardonnay in one hand - chocolate in the other - body thoroughly used up, totally worn out and screaming "WOO HOO, What a Ride"
I figured it out. I took some liberties in interpreting the assignment. It says to make two constructors, but doesn't explicitly state I had to implement them both in making only one savings and one checking account. As a class is flexible enough to be used with different applications with out being rewritten I decided to just implement one constructor.
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace _0804A_IT466_DavidSchmidtII_Unit4_Bank_Account { public partial class Form1 : Form { AccountSavings savingsAccount = new AccountSavings(.03); AccountChecking checkingAccount = new AccountChecking(.50); public Form1() { InitializeComponent(); } public int caseNumber = 0; public double chckFee = .50; public double interestRate = .03; public double interestBalance; public double retrieveBalance; public void openSavBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = false; closeSavBtn.Visible = true; openSavBtn.Visible = false; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 1; amountTxtBx.Focus(); } public void closeSavBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; closeSavBtn.Visible = false; openSavBtn.Visible = true; savDepositBtn.Visible = false; savWithdrawlBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 0; savingsAccount.credit(0); } public void openChckBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = false; closeChckBtn.Visible = true; openChckBtn.Visible = false; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 2; amountTxtBx.Focus(); } public void closeChckBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; closeChckBtn.Visible = false; openChckBtn.Visible = true; chckDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; caseNumber = 0; checkingAccount.credit(0 + chckFee); } public void chckDepositBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 3; amountTxtBx.Focus(); } public void chckWithdrawlBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = true; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 5; amountTxtBx.Focus(); } public void savDepositBtn_Click(object sender, EventArgs e) { depositLbl.Visible = true; withdrawlLbl.Visible = false; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 4; amountTxtBx.Focus(); } public void savWithdrawlBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = true; amountTxtBx.Visible = true; doneBtn.Visible = true; cancelBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 6; amountTxtBx.Focus(); } public void doneBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; if (openChckBtn.Visible == false) { chckDepositBtn.Visible = true; chckWithdrawlBtn.Visible = true; chckBalanceBtn.Visible = true; } if (openSavBtn.Visible == false) { savBalanceBtn.Visible = true; savWithdrawlBtn.Visible = true; savDepositBtn.Visible = true; savInterestBtn.Visible = true; } switch (caseNumber) { case 1: savingsAccount.credit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 2: checkingAccount.credit(Convert.ToDouble(amountTxtBx.Text) + chckFee); amountTxtBx.Text = ""; break; case 3: checkingAccount.credit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 4: savingsAccount.credit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 5: checkingAccount.debit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; case 6: savingsAccount.debit(Convert.ToDouble(amountTxtBx.Text)); amountTxtBx.Text = ""; break; default: amountTxtBx.Text = ""; break; } } public void cancelBtn_Click(object sender, EventArgs e) { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; if (openChckBtn.Visible == false) { chckDepositBtn.Visible = true; chckWithdrawlBtn.Visible = true; chckBalanceBtn.Visible = true; } if (openSavBtn.Visible == false) { savBalanceBtn.Visible = true; savWithdrawlBtn.Visible = true; savDepositBtn.Visible = true; savInterestBtn.Visible = true; } amountTxtBx.Text = " "; } public void chckBalanceBtn_Click(object sender, EventArgs e) { amountTxtBx.Visible = true; doneBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 0; retrieveBalance = checkingAccount.balanceInquery; amountTxtBx.Text = Convert.ToString(retrieveBalance); } public void savBalanceBtn_Click(object sender, EventArgs e) { amountTxtBx.Visible = true; doneBtn.Visible = true; chckDepositBtn.Visible = false; savDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; savWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; caseNumber = 0; retrieveBalance = savingsAccount.balanceInquery; amountTxtBx.Text = Convert.ToString(retrieveBalance); } public void savInterestBtn_Click(object sender, EventArgs e) { amountTxtBx.Visible = true; doneBtn.Visible = true; interestBalance = savingsAccount.calcInterest(); amountTxtBx.Text = Convert.ToString(interestBalance); } } }
Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways - Chardonnay in one hand - chocolate in the other - body thoroughly used up, totally worn out and screaming "WOO HOO, What a Ride"
beforehand, sorry for my english... 
I have some advices for you:
1. You have a lot of repeating code in your program. You should take out it to a method(s) and then call it...
(also in doneBtn_Click method you have switch operator, that no matter what do this: amountTxtBx.Text = ""; you could place this before of after switch)
2. And you can make you switch operator shorter (it has equals cases)
3. Instead of creating variables chckFee, interestRate I would create an accessors in classes to get them.
I think, that's all for a first sight.
4. Instead caseNumber you could use an enum, with work, you want to lock in. I think it would be more understandable.

I have some advices for you:
1. You have a lot of repeating code in your program. You should take out it to a method(s) and then call it...
(also in doneBtn_Click method you have switch operator, that no matter what do this: amountTxtBx.Text = ""; you could place this before of after switch)
2. And you can make you switch operator shorter (it has equals cases)
3. Instead of creating variables chckFee, interestRate I would create an accessors in classes to get them.
I think, that's all for a first sight.
4. Instead caseNumber you could use an enum, with work, you want to lock in. I think it would be more understandable.
Last edited by Antenka; Nov 12th, 2008 at 1:59 pm.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace _0804A_IT466_DavidSchmidtII_Unit5_Bank_Account { public partial class Form1 : Form { AccountSavings savingsAccount = new AccountSavings(interestRate); // create a savings account AccountChecking checkingAccount = new AccountChecking(chckFee); // create a checking account public Form1() { InitializeComponent(); } public int caseNumber = 0; // used to determin which method is envoking the done button static double chckFee = .50; // variable to store checking fee static double interestRate = .03; // variable to store interest rate public double interestBalance; // variable used to store retrieval of interest earned public double retrieveBalance; // variable used to store retrieval of account balance // retrieve initial deposit and enable savings account buttons public void openSavBtn_Click(object sender, EventArgs e) { openAccountBtns(); enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 1; amountTxtBx.Focus(); } // end openSavBtn method // add additional deposit to savings account public void savDepositBtn_Click(object sender, EventArgs e) { enabledepositBtns(); enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 3; amountTxtBx.Focus(); } // end savDepositBtn method // withdrawl money from savings account public void savWithdrawlBtn_Click(object sender, EventArgs e) { enableWithdrawlBtns(); enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 5; amountTxtBx.Focus(); } // end savWithdrawlBtn method // zero out savings account and disable account buttons public void closeSavBtn_Click(object sender, EventArgs e) { hideModifyAccountBtns(); hideSavBtns(); closeSavBtn.Visible = false; openSavBtn.Visible = true; caseNumber = 0; savingsAccount.debit(savingsAccount.balanceInquery); } // end closeSavBtn method // retrieve initial deposit and enable checking account buttons public void openChckBtn_Click(object sender, EventArgs e) { openAccountBtns(); enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 2; amountTxtBx.Focus(); } // end openChckBtn method // add additional deposit to checking account public void chckDepositBtn_Click(object sender, EventArgs e) { enabledepositBtns(); enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 4; amountTxtBx.Focus(); } // end chckDepositBtn method // withdrawl money from chekcing account public void chckWithdrawlBtn_Click(object sender, EventArgs e) { enableWithdrawlBtns(); enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 6; amountTxtBx.Focus(); } // end chkWithdrawlBtn method // zero out checking account and disable account buttons public void closeChckBtn_Click(object sender, EventArgs e) { hideModifyAccountBtns(); hideChckBtns(); closeChckBtn.Visible = false; openChckBtn.Visible = true; caseNumber = 0; checkingAccount.debit(checkingAccount.balanceInquery + chckFee); } // end closeChckBtn method // use switch/case to determin action to be performed when pressed public void doneBtn_Click(object sender, EventArgs e) { hideModifyAccountBtns(); try { switch (caseNumber) { case 1: savingsAccount.credit(Convert.ToDouble(amountTxtBx.Text)); if (savingsAccount.negativeNumber == false) { closeSavBtn.Visible = true; openSavBtn.Visible = false; } break; case 2: checkingAccount.credit(Convert.ToDouble(amountTxtBx.Text) + chckFee); if (checkingAccount.negativeNumber == false) { closeChckBtn.Visible = true; openChckBtn.Visible = false; } break; case 3: savingsAccount.credit(Convert.ToDouble(amountTxtBx.Text)); break; case 4: checkingAccount.credit(Convert.ToDouble(amountTxtBx.Text)); break; case 5: savingsAccount.debit(Convert.ToDouble(amountTxtBx.Text)); break; case 6: checkingAccount.debit(Convert.ToDouble(amountTxtBx.Text)); break; default: clearAmountTxtBx(); break; } } // end try catch (FormatException) { MessageBox.Show("You must enter an integer.", "Invalid Number Format", MessageBoxButtons.OK, MessageBoxIcon.Error); } // end catch finally { clearAmountTxtBx(); // check which accounts are opened and enable transactional buttons if (openChckBtn.Visible == false) { enableChckBtns(); } if (openSavBtn.Visible == false) { enableSavBtns(); } } } // end doneBtn method // cancel transaction public void cancelBtn_Click(object sender, EventArgs e) { hideModifyAccountBtns(); if (openChckBtn.Visible == false) { enableChckBtns(); } if (openSavBtn.Visible == false) { enableSavBtns(); } amountTxtBx.Text = " "; } // end cancelBtn method // retrieve checking account balance public void chckBalanceBtn_Click(object sender, EventArgs e) { enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 0; retrieveBalance = checkingAccount.balanceInquery; amountTxtBx.Text = Convert.ToString(retrieveBalance); } // end chckBalanceBtn method // retrieve savings account balance public void savBalanceBtn_Click(object sender, EventArgs e) { enableAmountDisplay(); hideChckBtns(); hideSavBtns(); caseNumber = 0; retrieveBalance = savingsAccount.balanceInquery; amountTxtBx.Text = Convert.ToString(retrieveBalance); } // end savBalanceBtn method // retrieve interest earned public void savInterestBtn_Click(object sender, EventArgs e) { enableAmountDisplay(); interestBalance = savingsAccount.calcInterest(); amountTxtBx.Text = Convert.ToString(interestBalance); } // end savInterestBtn method // clear amount text box public void clearAmountTxtBx() { amountTxtBx.Text = ""; } // end closeAccountBtns method //--------------------- Visible Buttons Methods --------------------------- // hide savings account transaction buttons public void hideSavBtns() { savDepositBtn.Visible = false; savWithdrawlBtn.Visible = false; savBalanceBtn.Visible = false; savInterestBtn.Visible = false; } // end hideSavBtns method // enable savings account transaction buttons public void enableSavBtns() { savBalanceBtn.Visible = true; savWithdrawlBtn.Visible = true; savDepositBtn.Visible = true; savInterestBtn.Visible = true; } // end enableSavBtns method // hide checking account transaction buttons public void hideChckBtns() { chckDepositBtn.Visible = false; chckWithdrawlBtn.Visible = false; chckBalanceBtn.Visible = false; } // end hideChckBtns method // enable checking account transaction buttons public void enableChckBtns() { chckDepositBtn.Visible = true; chckWithdrawlBtn.Visible = true; chckBalanceBtn.Visible = true; } // end enableChckBtns method // hide transaction buttons public void hideModifyAccountBtns() { depositLbl.Visible = false; withdrawlLbl.Visible = false; amountTxtBx.Visible = false; doneBtn.Visible = false; cancelBtn.Visible = false; } // end hideTransModifyBtns method // enable done button and amount text box public void enableAmountDisplay() { amountTxtBx.Visible = true; doneBtn.Visible = true; } // end enableAmountDisplay method // enable withdrawl buttons public void enableWithdrawlBtns() { depositLbl.Visible = false; withdrawlLbl.Visible = true; cancelBtn.Visible = true; } // end enableWithdrawlBtns method // enable deposit buttons public void enabledepositBtns() { depositLbl.Visible = true; withdrawlLbl.Visible = false; cancelBtn.Visible = true; } // end enabledepositBtns method // open account buttons public void openAccountBtns() { depositLbl.Visible = true; withdrawlLbl.Visible = false; cancelBtn.Visible = false; } // end openAccountBtns method } // end Class Form } // end namespace
Life should NOT be a journey to the grave with the intention of arriving safely in an attractive and well preserved body, but rather to skid in sideways - Chardonnay in one hand - chocolate in the other - body thoroughly used up, totally worn out and screaming "WOO HOO, What a Ride"
![]() |
Similar Threads
- Error:Null Pointer assignment (C++)
- Help Needed With OOP Bank Account..VB.Net (VB.NET)
- help needed with my assignment (C)
- Help me with my assignment! (C)
- bank account (C++)
- assignment needs a little help, well i do (C++)
Other Threads in the C# Forum
- Previous Thread: Image Manipulation
- Next Thread: Drag and drop items from forms to the desktop or to any entity outside the form.
| Thread Tools | Search this Thread |
.net access algorithm alignment app array bitmap box c# c#gridviewcolumn check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime decryption degrees developer draganddrop drawing encryption enum excel file focus form format forms function gdi+ grantorrevokepermissionthroughc#.net hospitalmanagementsystem image input install java label list mandelbroth marshalbyrefobject math messagebox mouseclick mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform plotting pointer polynomial post programming properties radians read regex remote remoting richtextbox server sleep socket sql statistics string stringformatting study sun table text textbox thread time timer update usb usercontrol validation visualstudio webbrowser winforms wpf wpfc# xml






