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...
-
A mobile phone is listed for $174 less 16 2/3%, 10%, and 8%. (a) What is the net price? (b) What is the total amount of discount allowed? (c) What is the exact single rate of discount that was...
-
Avis Company is a car rental company that is located three miles from the Los Angeles airport (LAX). Avis is dispatching a bus from its offices to the airport every 2 minutes. The average traveling...
-
Bert C. Roberts Jr. was chairman of WorldComs board of directors. Immediately before that, he had been chairman of MCI, which WorldCom acquired on September 14, 1998, in a transaction valued at...
-
Tuna Company set the following standard unit costs for its single product. Direct materials (25 Ibs. @ $4 per Ib.) . . . . . . . . . . . . . . . . . $100.00 Direct labor (6 hrs. @ $8 per hr.) . . . ....
-
Direct Labor Budgeted $14,200, Actual $14,200, Indirect Labor Budgeted 5,800, Actual 5,400, Utilities Budgeted 1,900, Actual 2,200, Rent Budgeted 3500, Actual 3500, Marketing Budgeted 150, Actual...
-
The shaft is supported by a smooth thrust bearing at B and a journal bearing at C. Determine the resultant internal loadings acting on the cross section at E. - 4 ft 4 ft +4 ft- 4 ft- 400 lb 800 lb
-
A textile manufacturing company is most likely to use job order costing to arrive at the cost per yard of textile manufactured and sold to customers. True False
-
Explain your level of exposure to the topic of research methods and statistics, emphasizing (a) where you obtained this exposure, (b) how long it has been since you took a course on these topics, and...
-
Mr. Arizona earned $107,300 (adjusted gross income) in 2017. After application of the relevant legal provisions, his taxable income was $86,362. The relevant portion of the tax table reads: If...
-
Below are hypothetical transactions of the United States during a given year. Figures are in billions of U.S. Dollars. They are not arranged in any particular order. Please note that not all entries...
-
What position would Adam Smith most likely support during a congressional debate on tax reform? (5 points)
-
Yesterday a chef used 16 eggs to make 9 chocolate souffles and 7 lemon meringue pies. The day before, he made 4 chocolate souffles and 7 lemon meringue pies, which used 11 eggs. How many eggs does...
-
6. The function f(x) = e3-x (1+e-x)2 is an example of a logistic distribution. 1. Verify that f is a probability density function. 2. Find P(3 x 4). 3. Use a computer to graph f, and then approximate...
-
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...
-
What are some differences among affirmative action, diversity, and inclusiveness?
-
What are some key ideas to remember when conducting a performance appraisal? What mistakes and best practices have you seen?
-
Why are these issues sometimes difficult to talk about? What could make conversations both more comfortable and productive?
Study smarter with the SolutionInn App