Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write java codes to implement the following requirements. You are require

ID: 3858212 • Letter: P

Question

Please write java codes to implement the following requirements. You are required to demonstrate (in your solutions) that you can apply inheritance/polymophism/interface(implementation)/comments(documentation) and additional java skills.

1. Create a JavaTransactionAccount class, so that one may store a name, an ID, account balance, and a list of transactions.

       Please maximize code re-use and extend your class from a Java class you have learned from this semester.   Then add additional information if some of them are not available from the super class.

2. Add a new instance field (called credit score) for each account.    Add new methods to process this field as needed.   

3. Implement a "Measurable" interface in your Java class so that we can find out the total # of transactions of each account.

4. Add codes in your java class to implement and override the .toString() method so that it returns the name, id, account balance and the total # of transactions. You do not need to include the detail listing of transactions in your .toString() output.

Explanation / Answer


import java.util.LinkedList;

/**
*
* @author Sam
*/
interface Measurable {
    void countTransaction();
    int getTransactionCount();
}

class Account {
    private String name;
    private String id;
    private double balance;

    public Account() {
        name = null;
        id = null;
        balance = 0;
    }

    public Account(String name, String id, double balance) {
        this.name = name;
        this.id = id;
        this.balance = balance;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }
  
  
  
}

public class JavaTransactionAccount extends Account implements Measurable{

    private LinkedList<String> transactions;
    private int transactionCount;

    public JavaTransactionAccount() {
        super();
    }

    public JavaTransactionAccount(LinkedList<String> transactions, String name, String id, double balance) {
        super(name, id, balance);
        this.transactions = transactions;
        countTransaction();
    }
  
  
  
    @Override
    public void countTransaction() {
        transactionCount = transactions.size();
    }

    @Override
    public int getTransactionCount() {
        return transactionCount;
      
    }


    @Override
    public String toString() {
        /* //or you can use this block for shortcut
        return transactions.toString(); */
        String outputString = "";
        for (String s:transactions)
            outputString += s + " ";
        return outputString;
    }
   
}


All features mentioned in the question are used. Let me know if you love it....