I have the following class:
public class Transaction {
public String Type;
public double Amount;
public double Balance;
Transaction(String Type,double Amount,double Balance){
this.Type = Type;
this.Amount = Amount;
this.Balance = Balance;
}
public String toString(){
String s = " Type: "+ Type +"\n Amount: "+ Amount+ "\n Balance: "+Balance;
return s;
}
This is used to create instance of transactions with my main class so I can eventually print out all transactions in a long list like a statement.
In my main class Account I have this code so far:
public class Account {
private String name;
private double balance;
public double initDeposit;
protected ArrayList<Transaction>;
public Account(String name, double initDeposit){
this.balance =initDeposit;
this.name = name;
Transaction a = new Transaction("Creation",initDeposit,balance);
}
I am trying to create a new transaction when a account is made and add it to the ArrayList but I am not declaring the array list properly. How could I do that? Thank you for any replies.
protected ArrayList<Transaction> giveMeAName;private String name;? This is the same thing.