Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We would like to design a class that stores information about a debit card. Since debit cards and credit cards have a lot of similarity,

We would like to design a class that stores information about a debit card. Since debit cards and credit cards have a lot of similarity, the commonality can be extracted to a superclass called ChargeCard. Then DebitCard and CreditCard are both subclasses of ChargeCard.

A fundamental difference between credit cards and debit cards is in how they make purchases, but realize that they both have the capacity to make purchases. A purchase increases the balance of a credit card while it decreases the balance of a debit card.

Some distinctions between a credit card and a debit card lie in how the user makes payments towards them. The bill can be paid on a CreditCard to decrease its balance while a deposit or withdrawal can affect the balance of a DebitCard. A credit card has a spending limit to limit the balance on the card. Purchases can be made on a debit card as long as there are funds in the account. The balance on a debit card can become negative, so long as the amount does not exceed the overdraft limit, in which case an overdraft fee is applied.

Do you think ChargeCard should be an abstract or a concrete class? Write a comment before the class begins in which you explain your design decision.

Make a parameterized constructor in the superclass that can be called from all of its subclasses.

Keep in mind: input and output should not be performed in the CreditCard or DebitCard or ChargeCard classes. All input and output to the user should be performed in the main method method (or other methods that are in a separate class) to increase flexibility of the classes we will design later on.

ChargeCard CreditCard DebitCard Debit Card Class

The fields in the DebitCard class should include the following. Realize that the data members that are shared with the CreditCard class should be implemented in the ChargeCard class to eliminate redundancy.

name. A String that holds the card holders name.

cardNumber. A field that holds the credit card number. balance. A double that stores the current credit card balance.

overdraftLimit. A double that stores the overdraft limit of the account.

overdraftFee. A double that stores the fee to apply whenever expenses exceed the balance.

feesIncurred. A double that keeps track of fees that the account holder owes. additional fields that you can think of.

The DebitCard class should support (at least) the following member methods:

Constructor. The constructor should accept the card holders name and card number and assign these values to the object's corresponding member variables. The constructor should initialize the overdraft fee to $50, the overdraft limit to $100, and the balance to $0.

Accessors. Appropriate accessor methods should be created to allow values to be retrieved from an object's member variables.

purchase. This method should subtract the amount specified as a parameter from the balance member variable each time it is called, and tap into the overdraft limit when necessary (and apply the overdraft fee whenever this happens).

increaseOverdraftLimit. This method should add 100 to the overdraftLimit member variable each time it is called.

depositFunds. This method should increase the balance as specified in a parameter.

withdrawFunds. This method should decrease the balance as specified in a parameter.

payFees. This method should reset the feesIncurred member variable to 0.

toString. Render the state of a DebitCard as a String.

Demonstrate the class in a program that creates a DebitCard object and allows the user to change and view the state of the debit card with a menu driven program.

1. View Card Information.

2. Purchase an Item: ask the user the purchase amount and decrease the card balance accordingly.

3. Make Deposit: ask the user how much money to deposit and call makeDeposit method to increase the balance accordingly.

4. Increase Overdraft Limit: ask the user how much the spending limit should be, and call the increaseSpendingLimit method the appropriate number of times.

5. Pay Fees: call the payFees member method to reset the fees incurred to 0.

Make sure that the menu-driven program you have already written for the CreditCard class still works as you expect it to!

Referrence to poorly written code: http://www.chegg.com/homework-help/questions-and-answers/credit-cards-inheritance-would-like-design-class-stores-information-debit-card-since-debit-q25356158 ( Classes are not properly organized. Data members that pertain to a specific subclass should be defined in that subclass. Similarly, if there is functionality that is limited to one subclass, it should be in a method in that subclass not the superclass.) This code has to be done all over again.This question has been already posted, but the answer was copied from other work and posted since that happens, I'm posting it again.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

1. Explain why evaluation is important.

Answered: 1 week ago