In: Computer Science
must be written in c# using windows forms not console
Scenario: Samediff bank has a 25-year old banking account system. It was created using procedural programming. Samediff bank needs to improve the security and maintainability of the system using an object-oriented programming (OOP) approach. Their bank manager has decided to hire you to develop, implement, and test a new OOP application using efficient data structures and programming techniques.Samediff banks manager is excited to consider updating their account system. An expert has advised that they would be able to increase both security and ease of maintenance by using object oriented concepts such as polymorphism.
Create an inheritance hierarchy that a bank will use to represent customers’ bank accounts. All customers of Samediff bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. Each month they process interest earned and penalties on each account. Specific types of accounts exist. Each type of account you will need to consider in your inheritance hierarchy is listed below.You will need to create a list of accounts, in which you will have different types of accounts. account[] accountslist=new account[10];
account[0]=new savings();
account[1]=new checking();
or List accounts; accounts.add(new checking());
accounts.add(new savings());
You must complete these steps in your code
1. A menu system to add customers and accounts, delete customers and accounts.
2. Print customers with each customers accounts sorted by the last name of each customer.
3. Demonstrate that one customer can have more than one account.
4. Demonstrate a deposit and withdrawal of a customers account balance.
5. Demonstrate earned interest on an account.
6. Demonstrate penalties applied to an account.
Hi hope you are good.
Here is the main program.
using System;
using System.Collections.Generic;
using System.Linq;
namespace BankExcercise
public class Bank
{
public string name;
private List<Account> bankAccounts;
public Bank(sting name)
{
this.name = name;
bankAccounts = new List<Account>();
}
public int OpenBankAccount(Type accountType, decimal startingBalance)
{
int newId = bankAccoiunts.Count();
bankAccounts.Add((Account)Activator.CreateInstance(accountType,newId,startingBalance));
return newId;
}
public Account GetAccount(int ownerId)
{
Account account = bankAccounts.Where(x=>x.owner == ownerId).FirstOrDefault();
if(account == null)
{
throw new ApplicationException("No Account exists with that id");
}
return account;
}
public bool Tranferfunds(int fromAccountId,int toAccountId, decimal transferAmount)
{
if(transferAmount<=0)
{
throw new ApplicationException("transfer amount must be positive");
}
else if (transferAmoiunt ==0)
throw new ApplicationException("Invalid Amount");
}
Account fromAccount = GetAccount(fromAccountId);
Account fromAccount = GetAccount(toAccountId);
if(fromAccount.balance<transferAmount)
{
throw new ApplicationException("Insufficient funds");
}
fromAccount.Transfer(-1*transferAmount,toAccoiuntId);
toAccount.Transfer(transferAmount,fromAccountId);
return true;
}
----------------------------------------------------------------
Abstract an account from which savings and chewckings would derive
using BankExcercise.Transactions;
using System;
using System.Collections.Generic;
namespace BankExcercise
{
public abstract class Account
{
public int owner { get; set;}
public decimal balance (get ; set;)
public List<Transaction> tranactions{get;set;}
public Account(int owner,decimal balance)
{
this.owner = owner;
this.balance = balance;
transactions = new List<Transactions>();
}
public virtual bool Withdrawl(decimal withdrawlAmount)
{
if (balance < withdrawlAmount)
{
throw new ApplicationException("Insufficient funds");
}
else if (withdrawalAmount<=0)
{
throw new ApplicationException("Invalid");
}
balance -=withdrawlAmount;
Transaction newTransaction = new WithdrawlTransaction(withdrawlAmount);
transactions.Add(newTransaction);
return true;
}
public void Transfer(decimal transfferAmount,int transferToId)
{
balance +=transferAmounbt;
TransferTransaction newTransaction = new TransaferTranscation(transferAmount,transferToId,owner)
transactions.Add(newTransaction);}
public void Deposit(decimal amount)
{
if(amount<=0)
{
throw new ApplicationException("Invalid Deposit Amout");
}
balance += amount;
Transaction newTransaction = new DepositTransaction(amount);
transactions.add(newTransaction);
}
}
}
Hope this helps.
You can write class for individual , saving and checkings as mentioned.
Askk me for any queries.