Create the CreditCard class. Every card has an account number, balance, owner, and credit limit. An account number is 16 digits and is stored as a String.
Credit cards need the following methods:
• initializing constructor
• apply a charge to the account: if the charge will cause the credit limit to be exceeded, do not apply the charge and return false, otherwise add the charge to the balance and return true
• equals to compare the account numbers
• a static method to validate an account number (described below)
• toString: put all fields on one line, do not label the fields
You do not need any set or get methods for the CreditCard class.
Storing Credit Cards:
Create a class AllCards to hold all of the credit cards. This class will use an ArrayList as a field to hold the cards. The class will need the following methods:
• constructor to instantiate the ArrayList
• create a card and add it to the ArrayList of cards
• process a purchase: check whether the card number is valid; if so, find the card in the list and attempt the purchase; if there is an error then throw an exception:
◦ 1 InvalidCardNumberException
◦ 2 CardNumberNotFoundException
◦ 3 OverdrawnException
• You need to create these Exception classes.
• toString: return a String which contains all of the credit cards stored in the ArrayList; add a newline between the cards so each card is on a separate line
When you are processing a purchase you need to search the credit cards to see if there is one for the given account number. This means that you need to search the ArrayList in the AllCards object to see whether it has a card with the given account number. To search the ArrayList use the indexOf method. This will return the location (in the ArrayList) of the matching card, or it will return -1 if there is no matching card. Then use the get method of ArrayList to retrieve the card. To use the indexOf method you must pass a CreditCard object because the ArrayList contains CreditCard objects; you can't pass an account number. Before you call indexOf, create a credit card with the given account number. The other fields don't matter, you can fill in 0 or null for each of them. The indexOf method uses the equals method of CreditCard to check whether a card is in the list, and the equals method only compares the account numbers, so it will work correctly. When the get method returns it will return the object from the ArrayList, which has the correct data in all fields.
You do not need any set or get methods for the AllCards class.
Your client code needs to do the following:
• create the AllCards object
• read the [login to view URL] file, creating the objects for the cards and adding them to the AllCards object
• process each transaction in the [login to view URL] file: check for errors and then either update the object for the credit card or add a message to the error log
• print the credit cards on the screen with headings
• do not put all of this code in main; make sure that you use other functions as appropriate
20 freelancers are bidding on average $122 for this job
Hi there this is Asad. I have a vast experience in java programming, i can surely help you out with the code. If you are looking to get a good grade. Contact me.
Hi Gentleman, This is Paul Devanesan has done [login to view URL] and [login to view URL] from IIT Madras. I am a technology expert, more than a decade I am developing and delivering applications on Java based technologies. I am a certified Jav More
Hi. I would like to do this project for you. This looks like an easy task to me and I can start right now and finish it in couple of hours. Message me to discuss more details about your project.