Question: Assume that we change the CreditCard class (see Code Fragment 1.5) so that instance variable balance has private visibility. Why is the following implementation of

Assume that we change the CreditCard class (see Code Fragment 1.5) so that instance variable balance has private visibility. Why is the following implementation of the PredatoryCreditCard.charge method flawed?

public boolean charge(double price) { boolean isSuccess = super.charge(price); if (lisSuccess) charge(5); return isSucce

public boolean charge(double price) { boolean isSuccess = super.charge(price); if (lisSuccess) charge(5); return isSuccess; // the penalty

Step by Step Solution

3.33 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The problem is that when a 5 penalty is assessed presumably ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction to Algorithms Questions!