Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package lab4.accountproject;
  7.  
  8. /**
  9. *
  10. * @author student
  11. */
  12. public class Account
  13. {
  14. private String accName="";
  15. private String acid="";
  16. private double balance= 0.0f;
  17. Transaction[] listOfTransaction;
  18. int totalNumberofTransaction=0 ;
  19. public Account()
  20. {
  21. System.out.println("This is Default Constructor");
  22. }
  23. public Account(String nm,String id,float b)
  24. {
  25. this.accName =nm;
  26. this.acid = id;
  27. this.balance = b;
  28. System.out.println();
  29. }
  30. public void deposit(double amount)
  31. {
  32. this.balance = this.balance + amount;
  33. }
  34. public void withdraw(double amount)
  35. {
  36.  
  37. this.balance = this.balance + amount;
  38. }
  39. public void transfer(int amount,Account receiver,Account sender)
  40. {
  41. if(this.balance>amount)
  42. {
  43. this.balance = this.balance-amount;
  44. receiver.deposit(amount);
  45. sender.addTransaction(sender, receiver, amount);
  46. }
  47. else
  48. {
  49. System.out.println("Not Enough Balance");
  50. }
  51.  
  52. }
  53. public void addTransaction(Account sender,Account receiver,double amount)
  54. {
  55.  
  56. Transaction t=new Transaction(sender, receiver, amount);
  57. listofTransaction[this.totalNumberofTransaction] = t;
  58. totalNumberofTransaction++;
  59. }
  60.  
  61. public void showAllTransaction(){
  62. for (int i = 0); i<=this.totalNumberofTransaction; i+++
  63. }
  64.  
  65.  
  66. public void showInfo()
  67. {
  68. System.out.println("Account Detail\n-----------");
  69. System.out.println("Account No - "+ this.acid);
  70. System.out.println("Account Name - "+ this.accName);
  71. System.out.println("Balance -- "+this.balance);
  72. System.out.println("Total No. of Transaction:" + this.totalNumberofTransaction);
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement