Code:
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 CSHARP_UNIT5_DRAFT4
{
public partial class Form1 : Form
{
Account account;
Account MyCheckingAccount;
Account MySavingsAccount;
decimal balance;
decimal transactionFee;
decimal interestRate;
public Form1()
{
InitializeComponent();
}
public class Account
{
private decimal accountBalance;
public Account(decimal balance)
{
this.accountBalance = balance;
}
public Account()
{
accountBalance = 0;
}
public virtual decimal Credit(decimal amount)
{
return this.accountBalance += amount;
}
public virtual decimal Debit(decimal amount)
{
return this.accountBalance -= amount;
}
public virtual decimal getBalance()
{
return accountBalance;
}
}
class CheckingAccount : Account
{
private decimal TransactionFee;
decimal checkingBalance;
public CheckingAccount(decimal balance, decimal TFee)
: base(balance)
{
TransactionFee = TFee;
}
public CheckingAccount(decimal TFee)
{
TransactionFee = TFee;
}
public override decimal Credit(decimal amount)
{
return base.Credit(amount - TransactionFee);
}
}
public override decimal Debit (decimal amount)
{
return base.Debit(amount + transactionFee);
}
class SavingsAccount : Account
{
private decimal interestRate;
private decimal interest;
public SavingsAccount(decimal balance, decimal intR)
: base(balance)
{
interestRate = intR;
}
public SavingsAccount(decimal intR)
{
interestRate = intR;
}
public virtual decimal CalculateInterest()
{
interest = interestRate * base.getBalance();
return interest;
}
private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.Items.Add("Checking");
this.comboBox1.Items.Add("Savings");
this.comboBox1.SelectedIndex = 0;
this.comboBox2.Items.Add("Credit");
this.comboBox2.Items.Add("Debit");
this.comboBox2.SelectedIndex = 0;
this.txtAmount.Text = "0.00";
}
private void btnSummary_Click(object sender, EventArgs e)
{
}
private void btnEnter_Click(object sender, EventArgs e)
{
switch (comboBox1.Text)
{
case "Checking":
account = MyCheckingAccount;
break;
case "Savings":
account = MySavingsAccount;
break;
}
switch (comboBox2.Text)
{
case "Credit":
account.Credit(decimal.Parse(txtAmount.Text));
break;
case "Debit":
account.Debit(decimal.Parse(txtAmount.Text));
break;
}
MessageBox.Show((balance).ToString("0.00"));
}
private void btnNewChecking_Click(object sender, EventArgs e)
{
transactionFee = decimal.Parse(txtTransaction.Text);
balance = decimal.Parse(txtBalance.Text);
if (balance == 0)
{
MyCheckingAccount = new CheckingAccount(transactionFee);
MessageBox.Show("Your Checking Account has now been created with a balance of $0."
+ "\n\n" + "Welcome to the bank of Unit 5.");
}
else
{
MyCheckingAccount = new CheckingAccount(balance, transactionFee);
MessageBox.Show("Your Checking Account has now been created with a balance of $" + balance
+ "\n\n" + "Welcome to the bank of Unit 5.");
}
}
private void btnNewSaving_Click(object sender, EventArgs e)
{
interestRate = decimal.Parse(txtRate.Text);
balance = decimal.Parse(txtSbalance.Text);
if (balance == 0)
{
MySavingsAccount = new SavingsAccount(interestRate);
MessageBox.Show("Savings account is now open. Balance is $0."
+ "\n\n" + "Welcome to the bank of Unit 5.");
}
else
{
MySavingsAccount = new SavingsAccount(balance, interestRate);
MessageBox.Show("Savings Account is now open. Balance is $" + balance);
}
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
string aboutString = "Programmed by: Victor E. Campudoni"
+ "\n\n" + "For Kaplan University IT466-01."
+ "\n\n" + "I attest that this is my own work.";
string captionString = "Bank Account: Unit 5 assignment";
MessageBox.Show(aboutString, captionString);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
}

New Topic/Question
Reply



MultiQuote





|