Question: Modify the Code Fragment 1 . 7 . 1 CreditCard class to include the following best practices in Java: 1 . Each class must be
Modify the Code Fragment CreditCard class to include the following best practices in Java:
Each class must be a subclass of something, if it is the superclass of the application, it must be a subclass of Java Object.
Every class must be in a separate file.
Create an application to test CreditCard class, and name it TestCreditCard or DemoCreditCard
Each class must have an override toString to output the class info as a native Java Object
Use this instead of naming parameters different from the class private members.
Use ArrayList instead of the standard array for the wallet.
Output credit cards with Balance
Use Collection Sort to sort credit cards by Balance in Descending order.
The application and its classes must have headers.Code Fragment : The CreditCard class.
public class Creditcard
private string customer; name of the customer eg "John Bowman"
private String bank; name of the bank eg "California Savings"
private string account; account identifier eg
private int limit; credit limit measured in dollars
protected double balance; current balance measured in dollars
Constructors
public CreditCardString cust, string bk string acnt, int lim double initialBal
customer cust;
bank ;
account acnt;
limit lim;
balance initialBal;
public CreditcardString cust, String bk string acnt, int lim
thiscust bk acnt, lim; use a balance of zero as default
Accessor methods
public String getCustomer return customer;
public string getBank return bank;
public String getAccount return account;
public int getLimit return limit;
public double getBalance return balance;
Update methods
public boolean chargedouble price make a charge
if price balance limit if charge would surpass limit
return false; refuse the charge
at this point, the charge is successful
balance price; update the balance
return true; announce the good news
public void makePaymentdouble amount make a payment
balance amount;
Utility method to print a card's information
public static void printSummaryCreditCard card
System.out.printlnCustomer card.customer;
System.out.printlnBank card.bank;
System.out.printlnAccount card.account;
System.out.printlnBalance card.balance; implicit cast
System.out.printlnLimit card.limit; implicit cast
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
