Advertisement
Hazem3529

Soultion

Nov 30th, 2015
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1.  
  2. using System;
  3. usingSystem.Collections.Generic;
  4. usingSystem.Linq;
  5. usingSystem.Text;
  6.  
  7. namespace bank_account
  8. {
  9. class BankAccount
  10. {
  11. protected intaccountno;
  12. protected string customer;
  13. protected double balance;
  14. protected DateTimeopendate;
  15.  
  16. public int Accountno
  17. { get { return accountno; } }
  18.  
  19. public string Customer
  20. { get { return customer; } }
  21.  
  22. public double Balance
  23. { get { return balance; } }
  24.  
  25. public DateTimeOpendate
  26. { get { returnopendate; } }
  27.  
  28. public BankAccount(int a, string c, double b)
  29. {
  30.  accountno = a;
  31.  customer = c;
  32.  balance = b;
  33.  opendate = DateTime.Now;
  34. }
  35.  
  36. public virtual void Display()
  37. {
  38.  Console.WriteLine("Account No.: {0} \nCustomer Name: {1} \nBalance: {2} \nOpen Date: {3}", accountno, customer, balance,          opendate);
  39.  }
  40.  
  41. public void Deposite(double amount)
  42. {
  43.  balance += amount;
  44.  Console.WriteLine("Balance after deposite {0} in it: {1}",amount,balance);
  45. }
  46.  
  47. public virtual void withdraw(double amount)
  48. {
  49.   if (amount > balance)
  50.   Console.WriteLine("amount is greater than balance, so Operation is Failed");
  51.   else
  52. {
  53.    balance -= amount;
  54.    Console.WriteLine("Balance after withdraw {0} from it: {1}", amount, balance);
  55. }
  56.  
  57. }
  58. }
  59.  
  60. class SpecialAccount : BankAccount
  61. {
  62. public double overlimit;
  63.  
  64.   public SpecialAccount(int a, string c, double b, double o)
  65.    : base(a, c, b)
  66. {
  67.    overlimit = o;
  68. }
  69.  
  70. public override void Display()
  71. {
  72.   base.Display();
  73.   Console.WriteLine("Overlimit: {0}",overlimit);
  74. }
  75.  
  76. public override void withdraw(double amount)
  77. {
  78.     if (amount > (balance + overlimit))
  79.    Console.WriteLine("amount is greater than balance, so Operation is Failed");
  80. else
  81. {
  82.   balance -= amount;
  83.   Console.WriteLine("Balance after withdraw {0} from it: {1}", amount, balance);
  84.   }
  85.  }
  86. }
  87.  
  88. classProgram
  89. {
  90. static void Main(string[] args)
  91.    {
  92. SpecialAccount s = newSpecialAccount(123, "bate5a", 3000, 1000);
  93. s.Display();
  94. s.Deposite(1000);
  95. s.withdraw(4500);
  96.      }
  97.   }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement