Question: PART I Credit Card Class Write a class named CreditCard that has (at least) the following member variables: name. A String that holds the card

PART I

Credit Card Class Write a class named CreditCard that has (at least) the following member variables:

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.

spendingLimit. A double that stores the spending limit of the card holder. additional fields that you can think of. In addition, the class should have (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 spending limit to $2,000 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 add the amount specified as a parameter to the balance member variable each time it is called, assuming the purchase does not cause the balance to exceed the customers spending limit.

increaseSpendingLimit. This method should increase the spending limit by $50 each time it is called.

payBill. This method should reset the balance to 0. toString. to render the state of a CreditCard as a String. Input validation: Whenever a credit card number is modified, verify that it is of reasonable length. Demonstrate the class in a program that creates a CreditCard object and allows the user to change and view the state of the credit card with a menu driven program.

1. View Card Information.

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

3. Pay Bill: call payBill method to set the balance to 0.

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

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

PART II

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!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!