Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using java Part A Include an equals method in both the CreditCard and DebitCard classes to compare two objects. Part B - Wallet class Write

using java

Part A Include an equals method in both the CreditCard and DebitCard classes to compare two objects. Part B - Wallet class Write a class called Wallet to store information about the current state of a wallet. A wallet has different compartments for the dollar bills, loose change, credit / debit cards and ID cards. Data Members should include: Amount of cash - keep track of value of dollar bills and value of change separately. Array of ChargeCards it can contain both CreditCards and DebitCards. Array of ID cards this can be simply an array of Strings. Its up to you how to store this information. Methods should include: at least two constructors accessor, mutator methods TotalCashOnHand - total value of dollar bills and change TotalCanSpend - includes both cash and amount that can be spent on credit / debit cards. a method that tells you how many ID Cards are in the wallet a method that tells you how many credit / debit cards are in the wallet a method that lets you add a credit / debit card to the set a method to append an ID card to the set toString method - should delegate to CreditCard class to print information about each credit card and DebitCard class to print information about each debit card. Remember to keep the design paradigms of data hiding and encapsulation in mind as much as possible. Delegate tasks to the component classes (of ChargeCard, DebitCard, CreditCard) whenever you can. Perform input validation as appropriate. Part C - Menu Driven Program Write a menu-driven program that allows the user to interact with a single Wallet object. 1. Print all information about Wallet. [This should call the toString method of the Wallet class.] 2. Add a Credit Card. [Prompt the user for information about the Credit Card] 3. Add a Debit Card. [Prompt the user for information about the Debit Card.] 4. Add an ID Card. [Prompt the user for information about the ID card.] 5. Add Cash. [Prompt the user for the value of additional coins or dollar bills.] 6. Make a purchase. [Should ask for purchase amount. Then let the user choose whether to pay with cash or charge card. If cash, make sure there is sufficient cash in the wallet to cover the purchase, and then deduct accordingly. If charge card, there should be a submenu in which the user chooses a card from the list to use. Then the system should check that the card can be used for that purchase, i.e., that there are sufficient funds available on that card, and actually process the purchase on the selected ChargeCard.] Part D Use an ArrayList to store the sets of ChargeCards and ID cards in the Wallet. Incorporate these changes in your menu-driven program so that the user can store an unlimited number of cards in the Wallet. Part E The debit and credit cards should implement the Comparable interface. This way the list of cards can be sorted before they are displayed to the user. You can use the Collections.sort method to sort an ArrayList. It is up to you to decide how the objects should be compared. The two fields that seem meaningful for ordering objects are ID number and current balance. It is up to you to decide whether the interface should be implemented in the ChargeCard class or in each of the subclasses. Part F Add additional functionality to your main program so that the user can remove an ID card or debit / credit card from the Wallet. Let the user select the card he would like to remove. This is possible since they are stored in ArrayLists and an ArrayList can grow and shrink as necessary. Part G Design a GiftCard class that also extends ChargeCard and integrate it in the Wallet class. Gift cards come preloaded with a specific amount of money and the user can never spend more than that predetermined amount.

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_2

Step: 3

blur-text-image_3

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 Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago