Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- usingSystem.Collections.Generic;
- usingSystem.Linq;
- usingSystem.Text;
- namespace bank_account
- {
- class BankAccount
- {
- protected intaccountno;
- protected string customer;
- protected double balance;
- protected DateTimeopendate;
- public int Accountno
- { get { return accountno; } }
- public string Customer
- { get { return customer; } }
- public double Balance
- { get { return balance; } }
- public DateTimeOpendate
- { get { returnopendate; } }
- public BankAccount(int a, string c, double b)
- {
- accountno = a;
- customer = c;
- balance = b;
- opendate = DateTime.Now;
- }
- public virtual void Display()
- {
- Console.WriteLine("Account No.: {0} \nCustomer Name: {1} \nBalance: {2} \nOpen Date: {3}", accountno, customer, balance, opendate);
- }
- public void Deposite(double amount)
- {
- balance += amount;
- Console.WriteLine("Balance after deposite {0} in it: {1}",amount,balance);
- }
- public virtual void withdraw(double amount)
- {
- if (amount > balance)
- Console.WriteLine("amount is greater than balance, so Operation is Failed");
- else
- {
- balance -= amount;
- Console.WriteLine("Balance after withdraw {0} from it: {1}", amount, balance);
- }
- }
- }
- class SpecialAccount : BankAccount
- {
- public double overlimit;
- public SpecialAccount(int a, string c, double b, double o)
- : base(a, c, b)
- {
- overlimit = o;
- }
- public override void Display()
- {
- base.Display();
- Console.WriteLine("Overlimit: {0}",overlimit);
- }
- public override void withdraw(double amount)
- {
- if (amount > (balance + overlimit))
- Console.WriteLine("amount is greater than balance, so Operation is Failed");
- else
- {
- balance -= amount;
- Console.WriteLine("Balance after withdraw {0} from it: {1}", amount, balance);
- }
- }
- }
- classProgram
- {
- static void Main(string[] args)
- {
- SpecialAccount s = newSpecialAccount(123, "bate5a", 3000, 1000);
- s.Display();
- s.Deposite(1000);
- s.withdraw(4500);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement