part 1, 2, 3 and 4. And write in each part. will rate to person who completes al
ID: 3541856 • Letter: P
Question
part 1, 2, 3 and 4. And write in each part. will rate to person who completes all 4.
Write a banking program that simulates the operation of your local bank. You should declare the following collection of classes. Class Account Data fields: customer (type Customer), balance, accountNumber, transactions array (type Transaction []). Allocate an initial Transaction array of a reasonable size (e.g., 20), and provide a real locate method that doubles the size of the Transaction array when it becomes full. Methods: getBalance, getCustomer, toString, setCustomerExplanation / Answer
public class Account { protected Customer customer; protected double balance; protected int accountNumber = 23020 ; protected String accountType; static Transaction[] transaction = new Transaction[20];//reallocate method to double the size of the array public Transaction[] reallocate(Transaction[] transaction){ Transaction[] trans = new Transaction[transaction.length * 2]; for (int i =0; i< transaction.length; i++ ){ trans[i] = transaction[i]; } return trans; }
public Account(Customer customer, double balance) { super(); this.customer = customer; this.balance = balance; this.accountNumber =accountNumber; }
// method getBalance() public double getBalance() { return balance; } // method getCustomer() public Customer getCustomer() { return customer; } // method setCustomer() public void setCustomer(Customer customer) { this.customer = customer; } public int getAccountNumber() { return accountNumber; }
public void setAccountNumber(int accountNumber) { this.accountNumber = accountNumber; }
public String getAccountType() { return accountType; }
public void setAccountType(String accountType) { this.accountType = accountType; }
//method toString @Override public String toString() { return "Account [Account number= "+ getAccountNumber()+", Account type ="+getAccountType()+" Balance=" + getBalance() + ", getCustomer()=" + getCustomer() + "]"; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.