Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package com.techelevator; public class CheckingAccount extends BankAccount { private static final int OVERDRAFT _ FEE = 1 0 ; / / Constructor with three arguments
package com.techelevator;
public class CheckingAccount extends BankAccount
private static final int OVERDRAFTFEE ;
Constructor with three arguments
public CheckingAccountString accountHolderName, String accountNumber, int balance
superaccountHolderName accountNumber, balance; Call superclass constructor
Constructor with two arguments
public CheckingAccountString accountHolderName, String accountNumber
superaccountHolderName accountNumber, ; Initialize balance to zero
@Override
public int withdrawint amount
int currentBalance getBalance; Get the current balance
System.out.printlnCurrent balance: currentBalance;
int newBalance currentBalance amount; Calculate the new balance after withdrawal
System.out.printlnNew balance after withdrawal: newBalance;
Check if the withdrawal amount exceeds the balance
if newBalance
If the new balance is negative, apply the overdraft fee
newBalance OVERDRAFTFEE;
System.out.printlnApplied overdraft fee. New balance after fee: newBalance;
Update the balance indirectly using the deposit method to ensure fee is applied
depositcurrentBalance newBalance;
return newBalance;
C:Program FilesEclipse Adoptiumjdkhotspotbinjavaexe" ea Didea.test.cyclic.buffer.sizejavaagent:C:Program FilesJetBrainsIntelliJ IDEA libideartjar:C:Program FilesJetBrainsIntelliJ IDEA binDfile.encodingUTFclasspath C:Users
ayelmrepositoryorgjunitplatformjunitplatformlauncherjunitplatformlauncherjar;C:Program FilesJetBrainsIntelliJ IDEA libideartjar;C:Program FilesJetBrainsIntelliJ IDEA pluginsjunitlibjunitrtjar;C:Program FilesJetBrainsIntelliJ IDEA pluginsjunitlibjunitrtjar;C:Users
ayelOneDriveDesktopmeritAmericaismaelromerostudentexercisesInheritanceexercisetargettestclasses;C:Users
ayelOneDriveDesktopmeritAmericaismaelromerostudentexercisesInheritanceexercisetargetclasses;C:Users
ayelmrepositoryorgjunitjupiterjunitjupiterapijunitjupiterapijar;C:Users
ayelmrepositoryorgopentestjopentestjopentestjjar;C:Users
ayelmrepositoryorgjunitplatformjunitplatformcommonsjunitplatformcommonsjar;C:Users
ayelmrepositoryorgapiguardianapiguardianapiapiguardianapijar;C:Users
ayelmrepositoryorgjunitjupiterjunitjupiterenginejunitjupiterenginejar;C:Users
ayelmrepositoryorgjunitplatformjunitplatformenginejunitplatformenginejar;C:Users
ayelmrepositoryorgjunitvintagejunitvintageenginejunitvintageenginejar;C:Users
ayelmrepositoryjunitjunitjunitjar;C:Users
ayelmrepositoryorghamcresthamcrestcorehamcrestcorejar" com.intellij.rtjunit.JUnitStarter ideVersionjunit @w@C:Users
ayelAppDataLocalTempideaworkingdirsjunit.tmp @C:Users
ayelAppDataLocalTempideajunit.tmp socket
Current balance:
New balance after withdrawal:
Current balance:
New balance after withdrawal:
Applied overdraft fee. New balance after fee:
java.lang.AssertionError: CheckingAccount withdraw method fails to decrease balance by correct amount. Starting balance: withdraw: new balance should be is greater than fee incurred expected: but was:
Expected :
Actual :
at org.junit.Assert.failAssertjava:
at org.junit.Assert.failNotEqualsAssertjava:
at org.junit.Assert.assertEqualsAssertjava:
at com.techelevator.CheckingAccountTest.testEdgeCaseTestsCheckingAccountTestjava:
at java.basejdkinternal.reflect.NativeMethodAccessorImpl.invokeNative Method
at java.basejdkinternal.reflect.NativeMethodAccessorImpl.invokeNativeMethodAccessorImpljava:
at java.basejdkinternal.reflect.DelegatingMethodAccessorImpl.invokeDelegatingMethodAccessorImpljava:
at java.basejavalang.reflect.Method.invokeMethodjava:
at org.junit.runners.model.FrameworkMethod$runReflectiveCallFrameworkMethodjava:
at org.junit.internal.runners.model.ReflectiveCallable.runReflectiveCallablejava:
at org.junit.runners.model.FrameworkMethod.invokeExplosivelyFrameworkMethodjava:
at org.junit.internal.runners.statements.InvokeMethod.evaluateInvokeMethodjava:
at org.junit.internal.runners.statements.RunBefores.evaluateRunBeforesjava:
at org.junit.runners.ParentRunner$evaluateParentRunnerjava:
at org.junit.runners.BlockJUnitClassRunner$evaluateBlockJUnitClassRunner.java:
at org.junit.runners.ParentRunner
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started