From 4973d451983619d68d5b95f31b8ef5688115f649 Mon Sep 17 00:00:00 2001 From: "ds.731" <122613372+ds731@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:48:07 -0600 Subject: [PATCH] Phase III - Added: - AccountInterface - CheckingAccount - SavingsAccount - Converted Account to abstract class - All instance variables are validated via exception handling --- .vscode/launch.json | 21 ++ bin/bankAcctApp/Account.class | Bin 2105 -> 2578 bytes bin/bankAcctApp/AccountInterface.class | Bin 0 -> 250 bytes bin/bankAcctApp/BankAcctApp.class | Bin 6028 -> 8622 bytes bin/bankAcctApp/CheckingAccount.class | Bin 0 -> 1367 bytes bin/bankAcctApp/Customer.class | Bin 2620 -> 2598 bytes bin/bankAcctApp/DataEntry.class | Bin 3944 -> 3938 bytes bin/bankAcctApp/SavingsAccount.class | Bin 0 -> 1325 bytes src/bankAcctApp/Account.java | 168 +++++---- src/bankAcctApp/AccountInterface.java | 10 + src/bankAcctApp/BankAcctApp.java | 472 +++++++++++++++++-------- src/bankAcctApp/CheckingAccount.java | 42 +++ src/bankAcctApp/Customer.java | 5 +- src/bankAcctApp/DataEntry.java | 15 +- src/bankAcctApp/SavingsAccount.java | 41 +++ 15 files changed, 535 insertions(+), 239 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 bin/bankAcctApp/AccountInterface.class create mode 100644 bin/bankAcctApp/CheckingAccount.class create mode 100644 bin/bankAcctApp/SavingsAccount.class create mode 100644 src/bankAcctApp/AccountInterface.java create mode 100644 src/bankAcctApp/CheckingAccount.java create mode 100644 src/bankAcctApp/SavingsAccount.java diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..77a7231 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "BankAcctApp", + "request": "launch", + "mainClass": "bankAcctApp.BankAcctApp", + "projectName": "Bank Account App_b3cd1e26" + } + ] +} \ No newline at end of file diff --git a/bin/bankAcctApp/Account.class b/bin/bankAcctApp/Account.class index eec17a4f7e5a9dfa3740c95f9527101110e9a3c9..ce3afd7933070c3131f41d427ac6824910de75ce 100644 GIT binary patch literal 2578 zcmZ{meODSs6vprJs<=TV;#*=vT4?}NDT!^38e5f`q#>~h)&$e`oB>v|DYBepF~@WI zE&4&)o>QBg^t2zKAFAndXBWYB_=A~Y=H5HMx%1qCfB$>;&-?eZML$L3X#TWO zt2rC3Rvx|8X*y8~X*Bjq9E*HIG!OGT)mKIhvk{H1D$E}=9m75lHAACI!j15_b5u2K zjS{6^l(J)+&BIlVMm(e4lNMYe?c>_Efq_=kNH;l_(RQ8+2UEIrY}iFx95~Vnr%^YOsjd{Y&({HqEXV_tmBxC{Dy6dlM+_2-*DMHYzn7i!!fI}S-VKN4!_8n z*)*MXje?o%o<^Z9t8T<7NK-mprio$FXhx?vjYR1R@+c2_e(xB~(iGc$pwlRgX*60g zn}(a4T~TfDK}uFlH1>pT@^^1C%!z!8LYhINnWl^E{F94kqu*%QWx&u})DM zf=~N`Pcn1y*nG}-FFfB6M_JHmn4`pdQQXTLhHcrqKV+%M#-HjGqY`M|Wy9&Kbb(41f z){x-^^~wO9#2eOOUwl9+GJ7%CMa7j3(UwL_MTmbTm2RhgPH~#O;l>fy=1OWly?E;Y zOWygsi5PuN_oB3Yu5gQ12ddKPK0VMVdMp|pW9IG62< zRX#5LwduU9+v2ro;DB|bWwlN4O^8;jae^ALJ4U@LD&JNfP!_LFtZa4cnz3ziMe1H@ zEpkDJu0wM{e8MQB0GARGdK81~p>x?oz_N!lWsgTe_9%Mzj>~a^5*Xv*K%2zOLm8JS znR`Q%x%eqf=l-JE${V_RN^`$UmuqMf6hb?MHjZt_;XXtu%;*RMXSz-wqSxpnn)d?d z(eqk3_Xnka!yrH$C?Y45ea_)C=N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P1^gCbt55_)5S9N1BlLmO diff --git a/bin/bankAcctApp/CheckingAccount.class b/bin/bankAcctApp/CheckingAccount.class new file mode 100644 index 0000000000000000000000000000000000000000..b6890db2b7cf3d814c361c6256bb219656a34ae7 GIT binary patch literal 1367 zcmZ`(TT>HB6#hC1B*Y1oIKxdH=81281Bm@TU`hlRs@pxtV zx!jd?5^dF2bVQ%$s?8z%f=gNaDp2an?sv7?aZo{(io%|$j*I=U{wFIn>y_M@%i*%X z{Z*Ri%6Mk(mgGKg{h-_1-1I$P1=?MY-ElX=h>4hxt3%fkoz3Gn)U%l7tSyCaF&zAk zs{+}Mfo%sr(P0O2-NB7RcMo;{CAAuy{|ELbhuhS%^mNtC;*Ntk+!ZLa!`5mfgRbC@h(_g%__-c#oM823Ou-#+>o@+8Azz+e;R?;t{lVdE{2*0FA#ZZ&@76zJMI} z69hd+_(=+yB9Up#P|_@g+#;xPI<}y3M5}>6aF29Sym6m3DQf}$`+Y_^?J_aXR)=#; XacAa8UIw{;juqSe_#7APtq1=D7ws0h literal 0 HcmV?d00001 diff --git a/bin/bankAcctApp/Customer.class b/bin/bankAcctApp/Customer.class index 4d7ef287cc8fb70592d751144709d9ae798dd22f..140b86e52320ae90adf5daea3738ed9d2ddcdae7 100644 GIT binary patch delta 20 bcmdlZvP@({EEA*e<`Smm?2I{+Ww;aoNFoLW delta 42 xcmZ1`vPWb?ER%S$b7^r&er{@!f@fY@eo<~>NoIbY71!oCrseF6xs%zr6aY#I4nhC` diff --git a/bin/bankAcctApp/DataEntry.class b/bin/bankAcctApp/DataEntry.class index 065a75c689f6ac2fda1f78663fed71983be5b81b..8435f09bf0ca5588b1bbe98508891eb0b09afa6c 100644 GIT binary patch delta 209 zcmaDM_egF-ET7{M1||j;1_lNzq3RtBwLU`4zMB~2wYD)RFK1BP#2~tjLDNrLcN;_N zHipib4D7nTIvarULcKr*I@=ifXZ^o7c{!hKeIbJ|LlJ`%LotIYLkWXALn(tMLpg&X zLm`6&LluJr(0nb3EeyI0dO#i3Bq7{-4NhgeSai0I-Y#ZVjro5Ud1rNOF;o1m$1fL)pZt04CK&xI(W(>^^k z!sRR`Fl+iGsk69##9a%0cK?oPXusMu6A%y;fx%j+teq#S6?ZLN*DWuwSshiamh*;F z@!PsybwlmzfZP8?tz=LXSl!sxU2Sq(1yZ@v?sc`*X=UWgjuB<($%u*C1xh(Ancfbw zw_VO>D%Ab=ULg8qQ0646PdCiz%Q;-ZRe>SLYi{_;4U}d2DRApQ){i%%vUq%t)Zr0Q zh1BMG9qXe&rfWbT9sA<&YhK&8^dsB6%EI4|ZP|cejj|#8&H;W0nb9?dxthywc*1}#mG+Te;4*5x`+%`hlr~M?+{dX;82pZj z7b8<&G4s<UL^)0wgpDapG>3VTp5<-|2|2*{+@XxeL^3k+ z9b&6Xd}JpZ;f?Xecn^O55I-N|3!KM=*xXy1OA&R&xEXr?F?O+FT$nBX7e{f?+o?vh zMT=HTOC!t0eO!88{LGsjpA*CZCNY316fi@kS^AN<#>li+M%q^nwXCpmof_sah84O_ jM6Qz%1#aFTM0aorMrLr-V%T~Iw-6!!JGh(Csat;lQ*Rhg literal 0 HcmV?d00001 diff --git a/src/bankAcctApp/Account.java b/src/bankAcctApp/Account.java index 975bc07..14092d1 100644 --- a/src/bankAcctApp/Account.java +++ b/src/bankAcctApp/Account.java @@ -1,80 +1,102 @@ -/* Phase II */ +/* Phase III */ package bankAcctApp; -public class Account { - - private String accountNumber; - private String accountType; - private Double svcFee; - private Double interestRate; - private Double overDraftFee; - private Double balance = 0.00; +import java.util.ArrayList; - -// Getter and Setter for Account Number info. - public String getAccountNumber() { - return accountNumber; - } - public void setAccountNumber(String accountNumber) { - this.accountNumber = accountNumber; - } - - -// Getter and Setter for Customer ID info. - public String getAccountType() { - return accountType; - } - public void setAccountType(String accountType) { - this.accountType = accountType; - } - - -// Getter and Setter for Service Fee info. - public Double getSvcFee() { - return svcFee; - } - public void setSvcFee(Double svcFee) { - this.svcFee = svcFee; - } - - -// Getter and Setter for Interest Rate info. - public Double getInterestRate() { - return interestRate; - } - public void setInterestRate(Double interestRate) { - this.interestRate = interestRate; - } - - -// Getter and Setter for Overdraft Fee info. - public Double getOverDraftFee() { - return overDraftFee; - } - public void setOverDraftFee(Double overDraftFee) { - this.overDraftFee = overDraftFee; - } +// Abstract class defining the structure for account types +public abstract class Account implements AccountInterface { + private String accountNumber; // Account number for each account + private String accountType; // Type of account (CHK or SAV) + private double svcFee; // Service fee for transactions + private double interestRate; // Interest rate for the account + private double overDraftFee; // Overdraft fee for checking accounts + private double balance = 0.00; // Initial balance of the account - -// Getter and Setter for Balance info. - public Double getBalance() { - return balance; - } - public void setBalance(Double balance) { - this.balance = balance; - } + // Transaction history stored as strings + private ArrayList transactionHistory = new ArrayList<>(); - -// Override the toString() method that is inherited by default in Java. -// Then use the custom-written toString() method to return Account Info -@Override - public String toString() { - return String.format( - "Acct#: Type: Svc Fee: Int Rate: Ovdft Fee: Balance: \n" + - "------ ----- -------- --------- ---------- -------- \n" + - "%-8s %-8s $%-10.2f %-12.1f $%-12.2f $%-9.2f", - accountNumber, accountType, svcFee, interestRate, overDraftFee, balance - ); - } + // Getter for account number + public String getAccountNumber() { + return accountNumber; + } + + // Setter for account number + public void setAccountNumber(String accountNumber) { + this.accountNumber = accountNumber; + } + + // Getter for account type + public String getAccountType() { + return accountType; + } + + // Setter for account type + public void setAccountType(String accountType) { + this.accountType = accountType; + } + + // Getter for service fee + public double getSvcFee() { + return svcFee; + } + + // Setter for service fee + public void setSvcFee(double svcFee) { + this.svcFee = svcFee; + } + + // Getter for interest rate + public double getInterestRate() { + return interestRate; + } + + // Setter for interest rate + public void setInterestRate(double interestRate) { + this.interestRate = interestRate; + } + + // Getter for overdraft fee + public double getOverDraftFee() { + return overDraftFee; + } + + // Setter for overdraft fee + public void setOverDraftFee(double overDraftFee) { + this.overDraftFee = overDraftFee; + } + + // Getter for account balance + public double getBalance() { + return balance; + } + + // Setter for account balance + public void setBalance(double balance) { + this.balance = balance; + } + + // Getter for transaction history + public ArrayList getTransactionHistory() { + return transactionHistory; + } + + // Method to log a transaction and store it in the transaction history + public String logTransaction(String date, String type, double amount) { + String transaction = String.format( + "Date: %s | Type: %s | Amount: $%.2f | Balance: $%.2f", + date, type, amount, this.balance + ); + transactionHistory.add(transaction); // Add transaction to history + return transaction; // Return the formatted transaction string + } + + // Abstract method for withdrawals, to be implemented in subclasses + public abstract void withdrawal(double amount); + + // Abstract method for deposits, to be implemented in subclasses + public abstract void deposit(double amount); + + // Abstract method for applying accrued interest + public abstract double applyAccruedInterest(String transactionDate); } \ No newline at end of file diff --git a/src/bankAcctApp/AccountInterface.java b/src/bankAcctApp/AccountInterface.java new file mode 100644 index 0000000..82c5a23 --- /dev/null +++ b/src/bankAcctApp/AccountInterface.java @@ -0,0 +1,10 @@ +/* Phase III */ + +package bankAcctApp; + +public interface AccountInterface { + void withdrawal(double amount); + void deposit(double amount); + double applyAccruedInterest(String date); + double balance(); +} \ No newline at end of file diff --git a/src/bankAcctApp/BankAcctApp.java b/src/bankAcctApp/BankAcctApp.java index 6e9cbcd..241774a 100644 --- a/src/bankAcctApp/BankAcctApp.java +++ b/src/bankAcctApp/BankAcctApp.java @@ -1,182 +1,344 @@ -/* Phase II */ +/* Phase III */ package bankAcctApp; import java.util.ArrayList; -import java.util.InputMismatchException; - public class BankAcctApp { - - public static void main(String[] args) { - // Create ArrayLists for the Customer and Account classes. Each ArrayList will store the instances - // created of its respective class, appending each new instance to the end of the list. - ArrayList customers = new ArrayList<>(); + public static void main(String[] args) { + + ArrayList customers = new ArrayList<>(); ArrayList accounts = new ArrayList<>(); boolean moreCustomers = true; - -// Create the loop that keeps adding Customer and Account instances until -// the user chooses to quit. + + // Add customers and accounts while (moreCustomers) { - - // Create instances of the both the Customer and Account classes. - // These will be stored in their respective class' ArrayList. - Customer customer = new Customer(); - Account account = new Account(); - -// Customer Information: + Customer customer = new Customer(); + Account account = null; + int inputCount = 0; + System.out.println("Enter details for new customer:\n"); - - // Collect and validate user input for Customer ID info. - try { - customer.setID(DataEntry.inputStringWithLimit("Customer ID (max 5 chars): ", 5)); - } catch (IllegalArgumentException e){ - System.out.println("Customer ID must be 5 alphanumeric characters only. Try again."); - } - - // Collect and validate user input for Social Security Number (SSN). - try { - customer.setSSN(DataEntry.inputNumericString("SSN (9 numeric chars): ", 9)); - } catch (IllegalArgumentException e) { - System.out.println("SSN must be exactly 9 digits. Try again."); - } - - // Collect and validate user input for Last Namee. - try { - customer.setLastName(DataEntry.inputStringWithLimit("Last Name (max 20 chars): ", 20)); - } catch (IllegalArgumentException e) { - System.out.println("Last Name must not contain numbers (0-9) or special characters " - + "(!@#$%^&*(){}[]|). Try again."); - } - - // Collect and validate user input for First Name. - try { - customer.setFirstName(DataEntry.inputStringWithLimit("First Name (max 15 chars): ", 15)); - } catch (IllegalArgumentException e) { - System.out.println("First Name must not contain numbers (0-9) " - + "or special characters (!@#$%^&*(){}[]|). Try again."); - } - - - // Collect and validate user input for Street Address. - try { - customer.setStreet(DataEntry.inputStringWithLimit("Street (max 20 chars): ", 20)); - } catch (IllegalArgumentException e) { - System.out.println("Street must be no more than 20 characters consisting of " - + "numbers, letters, spaces, and \" . , - ' \". Try again."); - } - - // Collect and validate user input for City. - try { - customer.setCity(DataEntry.inputStringWithLimit("City (max 20 chars): ", 20)); - } catch (IllegalArgumentException e) { - System.out.println("City must not contain numbers (0-9) or special characters " - + "(!@#$%^&*(){}[]|). Try again."); - } - - // Collect and validate user input for State. - try { - customer.setState(DataEntry.inputStringWithLimit("State (2 chars): ", 2)); - } catch (InputMismatchException e) { - System.out.println("State must be 2 letters only. Try again."); - } - - // Collect and validate user input for Zip Code. - try { - customer.setZip(DataEntry.inputNumericString("Zip (5 numeric chars): ", 5)); - } catch (NumberFormatException e) { - System.out.println("Zip Code must only contain 5 digits. Try again."); - } - - // Collect and validate user input for Phone Number. - try { - customer.setPhone(DataEntry.inputNumericString("Phone (10 numeric chars): ", 10)); - } catch (NumberFormatException e) { - System.out.println("Phone Number must only contain 9 digits."); - } - -// Store Customer information to the Customer instance. - customers.add(customer); - -// Account Information: - // Collect and validate user input for Account Number. - try { - account.setAccountNumber(DataEntry.inputNumericString("Account Number (5 numeric chars): ", 5)); - } catch (NumberFormatException e) { - System.out.println("Account Number can only be 5 digits. Try again."); - } - - // Collect and validate user input for Account Type. - try { - boolean validAcctType = false; - while (!validAcctType) { - String input = DataEntry.inputStringWithLimit("Account type ('CHK' or 'SVG' only): ", 3); - - if (input.equalsIgnoreCase("CHK") || input.equalsIgnoreCase("SAV")) { - account.setAccountType(input.toUpperCase()); - validAcctType = true; - } else { - System.out.println("Input for Account Type can only be 'CHK' or 'SVG'. Try again."); - } + + // Collect and validate customer ID + while (inputCount == 0) { + try { + customer.setID(DataEntry.inputStringWithLimit("Customer ID (max 5 chars): ", 5)); + } catch (IllegalArgumentException e) { + System.out.println("Customer ID must be 5 alphanumeric characters only. Try again."); + continue; // retry input if invalid } - } catch (InputMismatchException e) { - System.out.println("Invalid input. Please try again."); + inputCount++; } - - // Collect and validate user input for Service Fee. - try { - account.setSvcFee(DataEntry.inputDecimalInRange("Service Fee Amount (in dollars and cents): $", 0.00, 10.00)); - } catch (InputMismatchException e) { - System.out.println("Input must be a dollar amount between $0.00 - $10.00. Try again."); + + // Collect and validate SSN + while (inputCount == 1) { + try { + customer.setSSN(DataEntry.inputNumericString("SSN (9 numeric chars): ", 9)); + } catch (IllegalArgumentException e) { + System.out.println("SSN must be exactly 9 digits. Try again."); + continue; + } + inputCount++; } - - // Collect and validate user input for Interest Rate. - try { - account.setInterestRate(DataEntry.inputDecimalInRange("Interest Rate (percent between 0.0% and 10.0%: ", 0.0, 10.0)); - } catch (InputMismatchException e) { - System.out.println("Interest Rate must be entered as a decimial between 0.0% - 10.0%. Try again."); + + // Collect and validate Last Name + while (inputCount == 2) { + try { + customer.setLastName(DataEntry.inputStringWithLimit("Last Name (max 20 chars): ", 20)); + } catch (IllegalArgumentException e) { + System.out.println("Last Name must not contain numbers or special characters. Try again."); + continue; + } + inputCount++; } - - // Collect and validate user input for Overdraft Fee. - try { - account.setOverDraftFee(DataEntry.inputDecimal("Overdraft Fee Amount (in dollars and cents): $")); - } catch (InputMismatchException e) { - System.out.println("Input must be a dollar amount between $0.00 and $10.00"); + + // Collect and validate First Name + while (inputCount == 3) { + try { + customer.setFirstName(DataEntry.inputStringWithLimit("First Name (max 15 chars): ", 15)); + } catch (IllegalArgumentException e) { + System.out.println("First Name must not contain numbers or special characters. Try again."); + continue; + } + inputCount++; } - - // Collect and validate user input for Current Balance. - try { - account.setBalance(DataEntry.inputDecimal("Starting Balance (in dollars and cents): $")); - } catch (InputMismatchException e) { - System.out.println("Current Balance must be in dollars and cents. Try again."); + + // Collect and validate Street Address + while (inputCount == 4) { + try { + customer.setStreet(DataEntry.inputStringWithLimit("Street (max 20 chars): ", 20)); + } catch (IllegalArgumentException e) { + System.out.println("Street must be no more than 20 valid characters. Try again."); + continue; + } + inputCount++; } - -// Add the Account class instance to the accounts ArrayList + + // Collect and validate City + while (inputCount == 5) { + try { + customer.setCity(DataEntry.inputStringWithLimit("City (max 20 chars): ", 20)); + } catch (IllegalArgumentException e) { + System.out.println("City must not contain numbers or special characters. Try again."); + continue; + } + inputCount++; + } + + // Collect and validate State + while (inputCount == 6) { + try { + customer.setState(DataEntry.inputStringWithLimit("State (2 chars): ", 2)); + } catch (IllegalArgumentException e) { + System.out.println("State must be 2 letters only. Try again."); + continue; + } + inputCount++; + } + + // Collect and validate ZIP code + while (inputCount == 7) { + try { + customer.setZip(DataEntry.inputNumericString("Zip (5 numeric chars): ", 5)); + } catch (IllegalArgumentException e) { + System.out.println("Zip must be exactly 5 digits. Try again."); + continue; + } + inputCount++; + } + + // Collect and validate Phone Number + while (inputCount == 8) { + try { + customer.setPhone(DataEntry.inputNumericString("Phone (10 numeric chars): ", 10)); + } catch (IllegalArgumentException e) { + System.out.println("Phone number must be 10 digits only. Try again."); + continue; + } + inputCount++; + } + + // Add customer instance to customers ArrayList + customers.add(customer); + + // Collect and validate Account Type + while (inputCount == 9) { + try { + String accountType = DataEntry.inputStringWithLimit("Account type ('CHK' or 'SAV' only): ", 3).toUpperCase(); + if (accountType.equals("CHK")) { + account = new CheckingAccount(); + account.setAccountType("CHK"); + } else if (accountType.equals("SAV")) { + account = new SavingsAccount(); + account.setAccountType("SAV"); + } else { + throw new IllegalArgumentException("Account type must be 'CHK' or 'SAV'."); + } + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + continue; + } + inputCount++; + } + + // Collect and validate Account Number + while (inputCount == 10) { + try { + account.setAccountNumber(DataEntry.inputNumericString("Account Number (5 numeric chars): ", 5)); + } catch (IllegalArgumentException e) { + System.out.println("Account number must be exactly 5 digits. Try again."); + continue; + } + inputCount++; + } + + // Collect and validate Service Fee Amount + while (inputCount == 11) { + try { + account.setSvcFee(DataEntry.inputDecimalInRange("Service Fee (0.00 to 10.00): $", 0.00, 10.00)); + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + continue; + } + inputCount++; + } + + // Collect and validate Interest Rate Amount + while (inputCount == 12) { + try { + account.setInterestRate(DataEntry.inputDecimalInRange("Interest Rate (0.0% to 10.0%): ", 0.0, 10.0)); + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + continue; + } + inputCount++; + } + + // Collect and validate Overdraft Fee Amount + while (inputCount == 13) { + try { + account.setOverDraftFee(DataEntry.inputDecimal("Overdraft Fee (dollars and cents): $")); + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + continue; + } + inputCount++; + } + + // Collect and validate Starting Balance + while (inputCount == 14) { + try { + account.setBalance(DataEntry.inputDecimal("Starting Balance (dollars and cents): $")); + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + continue; + } + inputCount++; + } + + // Add account instance to accounts ArrayList accounts.add(account); - -// Prompt user to add additional customers or quit. - String more = DataEntry.inputStringWithLimit("\nAdd another customer? (y/n): ", 1); - if (more.equalsIgnoreCase("n")) { - moreCustomers = false; - } + + // Ask if more customers should be added + String more = DataEntry.inputStringWithLimit("\nAdd another customer? (y/n): ", 1); + moreCustomers = more.equalsIgnoreCase("y"); + System.out.println(); } -// Print out the results so that each Customer instance and its corresponding Account instance are -// printed together, and so the program iterates through all of the instance pairs in their respective ArrayLists. - System.out.println("\n========================================\n"); - for (int i = 0; i < customers.size(); i++) { + // Handle transactions + boolean addTransactionDetails = true; + // Start do-while loop add transaction details to any accounts + do { + String promptAddTransactions = DataEntry.inputStringWithLimit("Would you like to enter transaction details for an account? (y/n): ", 1).toUpperCase(); + if (!promptAddTransactions.equals("Y") && !promptAddTransactions.equals("N")) { + System.out.println("Please enter 'Y' or 'N' only."); + continue; // Prompt again if invalid input + } else if (promptAddTransactions.equalsIgnoreCase("N")) { + addTransactionDetails = false; // Exit the loop and proceed to report generation + } else if (promptAddTransactions.equalsIgnoreCase("Y")) { + boolean addTransactionsToAcct = true; + // Start do-while loop to add transaction entries to a specified account + do { + // Prompt for account number + String accountNumber = DataEntry.inputNumericString("Enter Account Number (5 digits): ", 5); + + // Find account and corresponding customer + Account selectedAccount = null; + Customer selectedCustomer = null; + + for (int i = 0; i < accounts.size(); i++) { + if (accounts.get(i).getAccountNumber().equals(accountNumber)) { + selectedAccount = accounts.get(i); + selectedCustomer = customers.get(i); + break; + } + } + + if (selectedAccount == null) { + System.out.println("Account not found. Please try again.\n"); + continue; // Prompt for account number again if not found + } + + // Display customer details for verification + System.out.println("Customer Information:"); + System.out.println(selectedCustomer); + + // Add transactions for the selected account + boolean newTransaction = true; + // Start do-while loop for "newTransactions + do { + String transaction = null; + int transactionStep = 0; + String transactionType = ""; + String transactionDate = ""; + + try { + while (transactionStep == 0) { + transactionType = DataEntry.inputStringWithLimit("\nTransaction Type ('DEP', 'WTH', or 'INT'): ", 3).toUpperCase(); + if (!transactionType.equals("DEP") && !transactionType.equals("WTH") && !transactionType.equals("INT")) { + System.out.println("Invalid transaction type. Please try again."); + } else { + transactionStep++; + } + } + } catch (IllegalArgumentException e) { + System.out.println("Type must be 'DEP', 'WTH', or 'INT' only. Try again"); + } + + while (transactionStep == 1) { + transactionDate = DataEntry.inputDate("Enter the transaction date (MM/DD/YYYY): "); + transactionStep++; + } + + while (transactionStep == 2) { + double amount = 0; + if (!transactionType.equals("INT")) { + amount = DataEntry.inputDecimal("Transaction Amount: $"); + } + + try { + if (transactionType.equals("DEP")) { + selectedAccount.deposit(amount); + transaction = selectedAccount.logTransaction(transactionDate, "DEP", amount); + } else if (transactionType.equals("WTH")) { + selectedAccount.withdrawal(amount); + transaction = selectedAccount.logTransaction(transactionDate, "WTH", amount); + } else if (transactionType.equals("INT")) { + double interest = selectedAccount.applyAccruedInterest(transactionDate); + transaction = selectedAccount.logTransaction(transactionDate, "INT", interest); + } + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + continue; + } + System.out.println(transaction + "\n"); + + // Ask if another transaction should be entered for this account + String anotherNewTransaction = DataEntry.inputStringWithLimit("Add another transaction for this account? (y/n): ", 1); + if (!anotherNewTransaction.equalsIgnoreCase("N") && !anotherNewTransaction.equalsIgnoreCase("Y")) { + System.out.println("Please enter 'Y' or 'N' only."); + continue; + }else if (anotherNewTransaction.equalsIgnoreCase("N")) { + newTransaction = false; + break; + }else if (anotherNewTransaction.equalsIgnoreCase("Y")) { + transactionStep = 0; + } + } + }while (newTransaction); + + // Ask if another account's transactions should be entered + String otherAcctTransactions = DataEntry.inputStringWithLimit("Enter transactions for another account? (y/n): ", 1); + if (!otherAcctTransactions.equalsIgnoreCase("N") && !otherAcctTransactions.equalsIgnoreCase("y")) { + System.out.println("Please enter 'Y' or 'N' only."); + continue; + } else if (otherAcctTransactions.equalsIgnoreCase("N")) { + addTransactionsToAcct = false; + break; + } + } while (addTransactionsToAcct); + } + } while (addTransactionDetails); + - // Use [int i] for both ArrayLists to ensure the correct Accounts instance is - // printed with the corresponding Customer instance. + + // Generate final report (this part should be in your existing code) + System.out.println("\n------------------------------|Final Report|-------------------------------"); + for (int i = 0; i < accounts.size(); i++) { Customer customer = customers.get(i); Account account = accounts.get(i); - System.out.println(customer + "\n"); + System.out.println(customer); + + System.out.println("Account Details:"); System.out.println(account); - System.out.println("---------------------------------------------------------" - + "----------------------------------------------------------------------------"); - + + System.out.println("Transactions:"); + for (String transaction : account.getTransactionHistory()) { + System.out.println(transaction); + } + System.out.println("------------------------------|End Report|-------------------------------"); } } -} +} \ No newline at end of file diff --git a/src/bankAcctApp/CheckingAccount.java b/src/bankAcctApp/CheckingAccount.java new file mode 100644 index 0000000..fb31cd2 --- /dev/null +++ b/src/bankAcctApp/CheckingAccount.java @@ -0,0 +1,42 @@ +/* Phase III */ + +package bankAcctApp; + +// Class representing checking accounts +public class CheckingAccount extends Account { + + // Overridden method for withdrawals in checking accounts + @Override + public void withdrawal(double amount) { + double newBalance = getBalance() - amount - getSvcFee(); // Deduct amount and service fee + if (newBalance < 0) { // Check for overdraft + newBalance -= getOverDraftFee(); // Apply overdraft fee if balance is negative + } + setBalance(newBalance); // Update balance + } + + // Overridden method for deposits in checking accounts + @Override + public void deposit(double amount) { + setBalance(getBalance() + amount - getSvcFee()); // Add amount and deduct service fee + } + + // Overridden method for applying accrued interest in checking accounts + @Override + public double applyAccruedInterest(String transactionDate) { + double interest = 0.0; + if (getBalance() <= 0.0) { // Ensure balance is positive for interest accrual + System.out.println("This account has an insufficient balance for interest to apply."); + } else { + interest = getBalance() * (getInterestRate() / 100); // Calculate interest + setBalance(getBalance() + interest); // Add interest to the balance + logTransaction(transactionDate, "INT", interest); // Log the interest transaction + } + return interest; + } + // Implementation of balance() method from AccountInterface + @Override + public double balance() { + return getBalance(); // Return the current balance + } +} \ No newline at end of file diff --git a/src/bankAcctApp/Customer.java b/src/bankAcctApp/Customer.java index c08dab6..0bd4093 100644 --- a/src/bankAcctApp/Customer.java +++ b/src/bankAcctApp/Customer.java @@ -1,4 +1,4 @@ -/* Phase II */ +/* Phase III */ package bankAcctApp; @@ -101,7 +101,6 @@ public class Customer { @Override public String toString() { return String.format( - "Customer Information:\n" + "---------------------\n" + "ID: Last Name: First Name: SSN: Phone: Street: City: ST: ZIP: \n" + "--- ---------- ----------- ---- ------ ------- ----- --- ---- \n" + @@ -109,4 +108,4 @@ public class Customer { id, lastName, firstName, ssn, phone, street, city, state, zip ); } -} +} \ No newline at end of file diff --git a/src/bankAcctApp/DataEntry.java b/src/bankAcctApp/DataEntry.java index e8329a5..c880d66 100644 --- a/src/bankAcctApp/DataEntry.java +++ b/src/bankAcctApp/DataEntry.java @@ -1,4 +1,4 @@ -/* Phase II */ +/* Phase III */ package bankAcctApp; @@ -110,16 +110,15 @@ public class DataEntry { Pattern patternDate = Pattern.compile("^(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])/(\\d{4})$"); String date = ""; System.out.print(prompt); - do { + while (date.isEmpty()) { String input = in.nextLine(); if (patternDate.matcher(input).matches()) { - return input; + date = input; + return date; } else { System.out.print("Invalid date. Please try again: "); - in.next(); - } - in.nextLine(); - } while (date.isEmpty()); + } + } return date; } -} +} \ No newline at end of file diff --git a/src/bankAcctApp/SavingsAccount.java b/src/bankAcctApp/SavingsAccount.java new file mode 100644 index 0000000..a73d0e8 --- /dev/null +++ b/src/bankAcctApp/SavingsAccount.java @@ -0,0 +1,41 @@ +/* Phase III */ + +package bankAcctApp; + +// Class representing savings accounts +public class SavingsAccount extends Account { + + // Overridden method for withdrawals in savings accounts + @Override + public void withdrawal(double amount) { + if (getBalance() >= amount + getSvcFee()) { // Ensure sufficient balance + setBalance(getBalance() - amount - getSvcFee()); // Deduct amount and service fee + } else { + throw new IllegalArgumentException("Insufficient funds for withdrawal. Savings accounts cannot overdraft."); + } + } + + // Overridden method for deposits in savings accounts + @Override + public void deposit(double amount) { + setBalance(getBalance() + amount - getSvcFee()); // Add amount and deduct service fee + } + + // Overridden method for applying accrued interest in savings accounts + @Override + public double applyAccruedInterest(String transactionDate) { + if (getBalance() <= 0) { // Ensure balance is positive for interest accrual + throw new IllegalArgumentException("The account has an insufficient balance for interest to apply."); + } + double interest = getBalance() * (getInterestRate() / 100); // Calculate interest + setBalance(getBalance() + interest); // Add interest to the balance + logTransaction(transactionDate, "INT", interest); // Log the interest transaction + return interest; + } + + // Implementation of balance() method from AccountInterface + @Override + public double balance() { + return getBalance(); // Return the current balance + } +} \ No newline at end of file