-
For programming assignment 3 we will be updating the
BankAccount
andEnhancedBankAccount
classes, to fill in the missing functionality. We have already reviewed the two classes.BankAccount
is a very basic class to implement the functionality of a bank account.EnhancedBankAccount
is a subclass ofBankAccount
, adding functionality of tracking all of the transactions. -
When you submit your program, you should rename
BankAcount
andEnhancedBankAcount
toyour_last_name_in_lower_case_BankAccount
andyour_last_name_in_lower_case_EnhancedBankAccount
(along with the corresponding changes to the class names, constructor names, and any statements instantiating aBankAccount
orEnhancedBankAccount
object).
Continuing on From Lab 04
- As part of lab 4 we updated
makeBankAccountsAndTransactions.java
to process transactions from a text file. This can be used as the starting point for testing your updates. And, you should be able to test the balance processing functionality for bothBankAccount
andEnhancedBankAccount
withmakeBankAccountsAndTransactions.java
.
Testing Transaction functionality
- During the week of 9/26/2022 we will discuss ideas on how to test the transaction tracking that the
EnhancedBankAccount
adds.
To ensure you get full credit for programming assignment 3, verify that all of the following is true for the methods implemented in lab04.
-
In
BankAccount
- In the withdraw and transfer methods, if there are insufficient funds to perform the operation, the method returns false and does not perform the operation. Otherwise it performs the operation and returns true.
- By "performs the operation", I mean adjust the savings and checking account balances based on the operation.
- In the deposit methods, the saving or checking account balance is properly adjusted based on the specified amount.
- The get methods return the appropriate values held in the fields of the class.
- The
toString()
method returns aString
of the following information (a,b,c should be on separate lines in the string returned by toString()):ownerLastName
,ownerFirstName
,accountNumber
checkingBalance
savingsBalance
-
In
EnhancedBankAccount
- The
Transaction
record can be used to create a transaction - The types of transactions supported should be {new EnhancedBankAccount, withdrawFromSavings, withdrawFromChecking, transferToChecking, transferToSavings, depositToSavings, depositToChecking}
- For the constructor of
EnhancedBankAccount
, there should be:- a “new EnhancedBankAccount” transaction added to the successful transactions.
- If the initial value for savings is greater than 0, then a “depositToSavings” transaction should be added to the successful transactions.
- If the initial value for the checking is greater than 0, then a “depositToChecking” transaction should be added to the successful transactions.
- (I believe this was provided for you in the start code given for lab04.)
- The
- The additional functionality that you need to implement is below. Most of the methods are very simple.
Update deposit, withdraw, and transfer methods in both classes
- If you didn't already do so, update the deposit, withdraw, and transfter methods to ignore the request if the specified amount is some negative value.
- In such a case, if the function returns a boolean, it should return false if the amount specified is negative.
Update deposit, withdraw, and transfer methods in EnhancedBankAcount class
- Update the deposit, withdraw, and transfer methods to apply the appropriate
operation, updating the
ArrayLists
ofTransactions
as appropriate
-
If successful, add a transaction of the appropriate type to the successfulTransactions ArrayList
-
If unsuccessful, add a transaction of the appropriate type to the failedTransactions ArrayList
Implement the following get transaction methods in the EnhancedBankAccount
- Add the following methods to the
EnhancedBankAccount
class:
/**
* Returns all the successful transactions involving some deposit to savings.
*
* @return all the successful depositToSavings transactions
*/
public java.util.ArrayList<Transaction> getSavingsDepositTransactions()
{
java.util.ArrayList<Transaction> results = new java.util.ArrayList<>();
for( Transaction t : successfulTransactions )
{
if( t.type().equals("depositToSavings") )
{
results.add(t);
}
}
return results;
}
/**
* Returns all the successful transactions involving some deposit to checking.
*
* @return all the successful depositToChecking transactions
*/
public java.util.ArrayList<Transaction> getCheckingDepositTransactions()
{
//TODO - implement
return null;
}
/**
* Returns all the successful transactions involving some withdrawal from savings.
*
* @return all the successful withdrawFromSavings transactions
*/
public java.util.ArrayList<Transaction> getSavingsWithdrawalTransactions()
{
//TODO - implement
return null;
}
/**
* Returns all the successful transactions involving some withdrawal from checking.
*
* @return all the successful withdrawFromChecking transactions
*/
public java.util.ArrayList<Transaction> getCheckingWithdrawalTransactions()
{
//TODO - implement
return null;
}
/**
* Returns all the successful transactions involving some transfer from savings to checking.
*
* @return all the successful transferFromSavingsToChecking transactions
*/
public java.util.ArrayList<Transaction> getSavingsToCheckingTransferTransactions()
{
//TODO - implement
return null;
}
/**
* Returns all the successful transactions involving some transfer from checking to savings.
*
* @return all the successful transferFromCheckingToSavings transactions
*/
public java.util.ArrayList<Transaction> getCheckingToSavingsTransferTransactions()
{
//TODO - implement
return null;
}
/**
* Returns all the transactions that were failed, and occured between the specified start and end dates.
*
* @return all the failed transactions within the specified start and end dates.
*/
public java.util.ArrayList<Transaction> getFailedTransactions(java.util.Date startDate, java.util.Date endDate)
{
//TODO - implement
return null;
}
/**
* Returns all the transactions that were successful, and occured between the specified start and end dates.
*
* @return all the successful transactions within the specified start and end dates.
*/
public java.util.ArrayList<Transaction> getSuccessfulTransactions(java.util.Date startDate, java.util.Date endDate)
{
//TODO - implement
return null;
}
-
Implement the get methods to return an
ArrayList<Transaction>
ofTransactions
of the appropriate type. I've implementedgetSavingsDepositTransactions()
as an example. -
For the get transactions methods, if they do not have the word successful or failed in the name, then you only need to return the successful transactions of that type
-
Implement the
getFailedTransactions
andgetSuccessfulTransactions
. Both methods take a starting date and ending date. Return the transactions of the appropriate type that are within the parameterized date range. The Java documentation explains how to compare dates.
Submission
When finished, be sure to push your code up to github, and then submit the latest commit hash on BrightSpace.
git add -A
git commit -m "finished programming assignment 3"
git push
git rev-parse HEAD