Account class The Account class not only defines the Account, it will also maintain a list (Collection) of Transaction objects. For simplicity – the Collection is to be an ​ArrayList. When the Account...

I need help in creating 3 methods and a little debugging. I've attached the requirements and my code. I have created the two classes along with constructors and setters/getters. TIA!


Account class The Account class not only defines the Account, it will also maintain a list (Collection) of Transaction objects. For simplicity – the Collection is to be an ​ArrayList. When the Account object is instantiated, the ​balance should be initialized to zero. addTransaction(Transaction) This method will add the Transaction to the ArrayList. When the transaction is added, the balance in the Account should be modified to reflect a DEBIT or CREDIT. reconcile() This method is to loop through the ArrayList and confirm the balance stated in the Account object is correct. Note the method returns a boolean value. Keep in mind what has been stated about keeping objects loosely coupled. Reconcile the entire ArrayList. As Transactions are added to the ArrayList, the balance in the Account class is to be updated. After all of the Transactions have been added to the ArrayList, reconcile the Account. Loop through the ArrayList and calculate the balance again. Compare the balance just calculated to the balance stored in the Account class. Confirm (or not) that the balances are the same, and the Account is reconciled. lookup(String transactionID) Loop through the ArrayList and find the Transaction related to the incoming transactionID. Once found, return that Transaction.If the method loops through the ArrayList and does not find a matching Transaction, return a null. Transaction Class The Transaction class will represent a single transaction.The type of Transaction will be identified through an enumeration (enum) CREDIT and DEBIT. When you create the Transaction in Eclipse, you can generate an .equals() method, along with your getters/setters, constructor, toString(), etc. Generate this .equals() method.The amount of the ​Transaction cannot be more than $99,999.99. Thus, a validation method for the amount will be required. Insert the Transaction into the ArrayList in ascending sorted order by transactionId. ​Use of the Collection’s sort method is not allowed. Main Class 1) The main will need to create an Account object 2) 10 Transaction objects are to be instantiated, and then added to the Account. 3) After the Transaction objects have been added to the Account’s ArrayList, the reconcile method needs to be called and appropriate messages written to indicate the account is balanced or not 4) Choose one of the transactions you have added to the ArrayList. Using the transaction ID from that Transaction object, call the Account’s lookup method and find the corresponding Transaction object. Using the .equals() method you added to the Transaction class, confirm the original Transaction and the returned Transaction are indeed equal. Print appropriate message. 5) Call the lookup method with a transaction ID that does not exist and should not be in the ArrayList of the Account object. Print the appropriate message. *​You do not need to prompt the user for input in the main method. Junit Tests Junit tests will be necessary for the amount in the Transaction. ​There should be three Junit tests for the amount – a negative test case for an amount less than the acceptable range, a negative test case for an amount greater than the acceptable range, and finally a happy path test within the acceptable range.
Feb 16, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here