Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Include an equals method in both the CreditCard and DebitCard classes to compare two objects. Part B - Wallet class Write a class called
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. Ir's 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 infomation 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. Extra credit: 1. 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. [3 points] 2. 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. [5 points]
Step by Step Solution
★★★★★
3.38 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Testerjava import javautilScanner public class Tester public static void mainString args Wallet wallet new Wallet1246 while true SystemoutprintlnChoose action Systemoutprintln0 Exit Systemoutprintln1 ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Document Format ( 2 attachments)
635da46dec05a_177593.pdf
180 KBs PDF File
635da46dec05a_177593.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started