Java Reference
In-Depth Information
this .customer = customer;
accountNumber = accountCounter ;
accountCounter++;
balance = initialDeposit ;
public boolean withdraw( double amount , Employee employee ) {
if (balance > amount) {
balance = amount ;
Transaction newTransaction = new Transaction( this ,employee,
TransactionType .withdraw , amount) ;
transactions .add(newTransaction) ;
return true ;
return false ;
} public void deposit( double amount , Employee employee )
{
Transaction newTransaction = new Transaction( this ,employee,
TransactionType . deposit , amount) ;
transactions .add(newTransaction) ;
balance += amount;
} public String toString() {
return "Bank account number: " +accountNumber+ " balance: " +balance ;
} public long getAccountNumber () {
return accountNumber ;
}
}
enum TransactionType
{
withdraw , deposit
}
public class Transaction implements Serializable
{
private static long idCounter = 0;
private Date date ;
private long accountNumber ;
private Employee employee ;
private TransactionType type ;
private double amount ;
private long transactionID;
public Transaction (BankAccount bankAccount , Employee employee ,
TransactionType type , double amount)
{
date = new Date () ;
this . accountNumber = accountNumber ;
this . employee = employee ;
this .type = type;
this . amount = amount ;
this . transactionID = idCounter ;
idCounter++;
} public String toString() {
return "Transaction id: " +transactionID+ " amount: " +amount+ "type: "
+type.name()+ " employeeID: " +employee+ " Date: " +date ;
 
Search WWH ::




Custom Search