Ass 5 (Property - Collection-Iterator)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment 5

Create a C# program with the following description:


Sr No. Description
1 Class Account represents an account. Each account include accNo, name, balance.
- Create the properties for instance variables with following features:
o pAccNo: has format TKxxxxx , x: digits
o pBalance >0
o pName doesn’t accept an empty string
o pDeposit (write only): rollback transaction if amt < 50
o pWithdraw (write only): rollback transaction if amt <50 or amt> balance
- Constructors
- Methods:
- void Accept()
- String ToString()
- void PrintInfo()

2 Class BankA has a collection SortedList<String,Account> named arList to store Account objects.
Methods:
- void AddNewAcc()
- IEnumerator<Account> GetEnumerator() return list of accounts.
- Account Search(String AccNo) return object Account which Account no is AccNo, or return null if
not found.
- void Transfer ( Account sender, Account receiver, int amount) transfers money between the
two accounts sender and receiver
- void Deposit ( string AccNo, int amount ) doing deposit transaction
- void Withdraw ( string AccNo, int amount ) withdraw transaction

3 Finally create the Main class which contains main method.


The main method will help user manipulate on Account list through a menu as following:

1- Add new Account


2- Print all Account
3- Deposit
4- Withdraw
5- Transfer Money
6- Search an Account by AccNo
7- Exit

You might also like