Include an equals method in both the CreditCard and DebitCard classes to compare two objects. Part...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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] 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]
Expert Answer:
Answer rating: 100% (QA)
Testerjava import javautilScanner public class Tester public static void mainString args Wallet wallet new Wallet1246 while true SystemoutprintlnChoose action Systemoutprintln0 Exit Systemoutprintln1 ... View the full answer
Related Book For
Database management systems
ISBN: 978-0072465631
3rd edition
Authors: Raghu Ramakrishan, Johannes Gehrke, Scott Selikoff
Posted Date:
Students also viewed these computer network questions
-
Write a memo to the client discussing the current state of convergence between IFRS and US GAAP on leases. Describe the similarities and differences in accounting for leases under the international...
-
How does a designer know whether to store information about an object as an attribute or to create subclasses?
-
Write an op-ed on the current state of the national security process?
-
A ball, which we can treat as a point charge, has a charge of +Q. This ball is 50 cm away from a ball of charge-100, which is fixed in position. The +Q ball is 30 cm vertically below, and 40 cm...
-
Prepare a table that summarizes some of the key advantages and limitations of mail, e-mail, telephone, and personal interview approaches for administering questionnaires.
-
In your audit of the Strangelove Group, a privately-held company based in Great Britain, you encountered the following situations: a. The internal control plans in the payables processing area are...
-
How can computers be used to assist in the litigation process?
-
In this chapter we discuss the Joe Paterno matter at Penn State. Another situation where a respected individuals reputation was tarnished by personal decisions having nothing to do with performance...
-
Why does the financial expense/EBITDA ratio play such a fundamental role in scoring techniques? What are the accounting items corresponding to additions to wealth for shareholders, lenders and the...
-
Simulation can be used to illustrate a number of results from statistics that are difficult to understand with non-simulation arguments. One is the famous central limit theorem, which says that if...
-
Consider a nonsymmetric real matrix A which has the Schur decomposition A = QRAH where Q is unitary, and R is upper trian- gular. (a) Show that q which is the first column of Q is an eigenvector of...
-
Divisional Income Statements and Return on Investment Analysis E.F. Lynch Company is a diversified investment company with three operating divisions organized as investment centers. Condensed data...
-
Playfair Limited is a company that purchases toys from abroad for resale to retail stores on credit. The company is concerned about its inventory (stock) management operations. It is considering...
-
- Use the Net income for tax purposes Federal tax payable before tax credit (Gross tax) Tax credits available Federal tax payable for 2020. (Do not consider provincial tax payable) information to...
-
solve x3-12x+39x-20
-
Cumulated Balance Sheet Sample Problem Consider the Cumulated Balance Sheets for the Federal Reserve System and the Commercial Banking System. All figures are in billions of US dollars. Federal...
-
Ten annual returns are listed in the following table: (Click on the following icon in order to copy its contents into a spreadsheet.) -19.8% 16.8% 18.2% -49.4% 43.3% 1.9% a. What is the arithmetic...
-
The diameter of a sphere is 18 in. Find the largest volume of regular pyramid of altitude 15 in. that can be cut from the sphere if the pyramid is (a) square, (b) pentagonal, (c) hexagonal, and (d)...
-
Answer the following questions about Extendible Hashing: 1. Explain why local depth and global depth are needed. 2. After an insertion that causes the directory size to double, how many buckets have...
-
Consider a relation R with five attributes ABCDE. 1. For each of the following instances of R, state whether it violates (a) the FD BC D and (b) the MVD BC D: (a) { } (i.e., empty relation) (b)...
-
Briefly answer the following questions: 1. Explain the following terms and describe what they are used for: HTML, URL, XML, Java, JSP, XSL, XSLT, servlet, cookie, HTTP, CSS, DTD. 2. What is CGI? Why...
-
A cargo ship containing many boxes is at sea and experiences rough motion. Consider two masses in the cargo hold that are in close proximity when mass \(m_{1}\) is subjected to a force \(F=A \cos...
-
Suppose the system of Equation 6.38, \[ \begin{aligned} & {\left[\begin{array}{cc} m_{1} & 0 \\ 0 & m_{2} \end{array} ight]\left\{\begin{array}{l} \ddot{x}_{1} \\ \ddot{x}_{2} \end{array} ight\}} \\...
-
For the undamped vibration absorber problem governed by Equations 6.45 and 6.46, \[ \begin{aligned} m_{1} \ddot{x}_{1}+\left(k_{1}+k_{2} ight) x_{1}-k_{2} x_{2} & =f_{1} \sin \omega t \\ m_{2}...
Study smarter with the SolutionInn App