Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Required Skills Inventory Write an derived class in Java according to Inter faces pecifications given in UML. Implement base class Interfaces in java according to

Required Skills Inventory

  • Write an derived class in Java according to Inter faces pecifications given in UML.
  • Implement base class Interfaces in java according to specifications given in UML.

Problem Description and Given Info

You must write a public classnamed CreditcardAccount with fields and methods asdefined below, and that inherits from (extends)the BankAccount class.

UML CLass Diagram: CreditcardAccount InheritsBankAccount

Structure of the Fields

As described by the UML Class Diagram above,your CreditcardAccount class must have the followingfields:

  • a private field named limit oftype int initialized to 0

Structure of the Methods

As described by the UML Class Diagram above,your CreditcardAccount class must have the followingmethods:

  • a public method named debit that takesan int argument and returns a boolean
  • a public method named setLimit that takesan int and returns nothing
  • a public method named getLimit that takesno arguments and returns an int
  • a public method named applyInterest thattakes no arguments and returns nothing
  • a public method named accountInfo thattakes no arguments and returns a String

Note that three of these methods are definedas abstract in the BankAccount base class. Youwill be overriding and implementing these methods inthis CreditcardAccount concrete derived class.

Behavior of the Methods

  • The debit method should subtract the argument amountfrom the currentBalance, but only if the amount would notcause the current balance to violate the credit limit. Thismethod should return true if the amount was subtractedfrom the currentBalance, otherwise it shouldreturn false.
  • The setLimit method should store the argument amountin the limit field.
  • The getLimit method should return the value stored inthe limit field.
  • The applyInterest method should compute the interestamount and add this amount to the currentBalance, but only ifthe currentBalance is less than 0.
  • The accountInfo method will returna string formatted exactly like this:
Type of Account : CreditcardAccount ID      : 1111-2222-3333-4444Current Balance : $123.45Interest rate   : 1.50%Credit Limit    : $10000.00
  • Note that, while the current balance ofa CreditcardAccount will almost always be negative, itshould be shown as a positive value inthe String returned bythe accoutnInfo method.

Additional Information

BankAccount Class

Copy and paste your BankAccount class code fromyour Bank Account (IndividualAssignment) into the BankAccount.Java filein the editor below.

All Bank Accounts

  1. All accounts have balance, credit and debit amounts, fees, andlimits stored and passed as a number of pennies (int).
  2. All debit amounts will be subtracted from the balance, and allcredit amounts will be added to the balance.
  3. All bank accounts have a non-negative interest rate(0.02 would be a 2% interest rate).
  4. When applying interest, interest amount is calculated bymultiplying the balance by the interest rate.
  5. When applying interest, interest amount is always added to thebalance, and any fractional part will be rounded down.
  6. Interest will not be applied toany Savings or Checking accountwith a balance of zero or less.
  7. Debit methods will return false if the transactioncannot be made because of insufficient balance or insufficientcredit limit. Otherwise they will return true.
  8. The credit method will always return true.

Creditcard Accounts

  1. The balance of a CreditcardAccount cannot overrun itscredit limit.
    • The debit method will return false if anattempt to overdraw the account is made.
    • The balance of a CreditcardAccount will generally benegative, because when you spend money on a credit card, you areborrowing money, and the negative balance reflects money that youowe.
  2. The credit limit will be stored as a positive value.For example, a credit limit of $10000.00 will be storedin the limit field asthe int value 1000000.
  3. Interest will not be applied toa CreditcardAccount with a positive or zerobalance.image

BankAccount < > # accountID: String # interestRate: double # currentBalance : int + credit(pennies: int) : boolean + debit(pennies: int): boolean < > + getBalance(): int + getAccountID(): String + setAccountID(accountID: String) + getinterestRate() : double + setInterestRate (interestRate: double) + applyInterest() < > + accountInfo(): String < > - limit: int Inherits/Extends CreditcardAccount + debit(pennies: int): boolean + getlimit(): int + setlimit(creditLimit: int) + applyInterest() + accountInfo() : String

Step by Step Solution

3.39 Rating (161 Votes )

There are 3 Steps involved in it

Step: 1

CreditcardAccountJava public class CreditcardAccount extends BankAccount declare private field private int limit Initialize limit to 0 public Creditca... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Statistics In Practice

Authors: Bruce Bowerman, Richard O'Connell

6th Edition

0073401838, 978-0073401836

More Books

Students also viewed these Electrical Engineering questions