Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package lab4.accountproject;
- /**
- *
- * @author student
- */
- public class Account
- {
- private String accName="";
- private String acid="";
- private double balance= 0.0f;
- Transaction[] listOfTransaction;
- int totalNumberofTransaction=0 ;
- public Account()
- {
- System.out.println("This is Default Constructor");
- }
- public Account(String nm,String id,float b)
- {
- this.accName =nm;
- this.acid = id;
- this.balance = b;
- System.out.println();
- }
- public void deposit(double amount)
- {
- this.balance = this.balance + amount;
- }
- public void withdraw(double amount)
- {
- this.balance = this.balance + amount;
- }
- public void transfer(int amount,Account receiver,Account sender)
- {
- if(this.balance>amount)
- {
- this.balance = this.balance-amount;
- receiver.deposit(amount);
- sender.addTransaction(sender, receiver, amount);
- }
- else
- {
- System.out.println("Not Enough Balance");
- }
- }
- public void addTransaction(Account sender,Account receiver,double amount)
- {
- Transaction t=new Transaction(sender, receiver, amount);
- listofTransaction[this.totalNumberofTransaction] = t;
- totalNumberofTransaction++;
- }
- public void showAllTransaction(){
- for (int i = 0); i<=this.totalNumberofTransaction; i+++
- }
- public void showInfo()
- {
- System.out.println("Account Detail\n-----------");
- System.out.println("Account No - "+ this.acid);
- System.out.println("Account Name - "+ this.accName);
- System.out.println("Balance -- "+this.balance);
- System.out.println("Total No. of Transaction:" + this.totalNumberofTransaction);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement