4.3 Problem Constraints The following statements apply to the problem domain: ? A unique card is identified by its card number (Primary Account Number or PAN) and expiry date. ? A customer may have multiple cards, however a card is only linked to a single customer. ? A card is not linked to an account. It is linked to a customer. ? For the purposes of this exercise, a customer may have one or more accounts but will only ever have one of a particular type (savings, current, credit). ? A transaction request will always provide enough detail to look up the correct customer and account to be transacted against, but there is no guarantee that the card exists, that the card is linked to a valid customer or that the customer has any accounts. In this case the transaction should be declined.
Hint 1: When a Card Processor (the class you are writing) is created it is linked to a DataStore. You can access this data store by calling the method getDataStore(). Initially a DataStore it is empty. You can add Customer, Account and Card objects to it one-by-one to do some testing. When your Card processor is tested by running the Transaction Processor the DataStore will be filled with random data before your Card Processor is initialized. Hint 2: The provided DataStore is not optimally organized. ? It can only return iterables (See java.lang.Iterable<T>) of each object type. ? Customer objects do not have any reference to the cards/accounts that are linked to them. Designing new internal data structures may make queries against the data easier. See ACardProcessor.init(). Hint 3: The relationship between the objects in the problem domain is shown below. Note that a Card is uniquely identified by a combination of the card number and expiry date and an account by the account number and account type.
5.1 Exercise 1 Implement the findLinkedAccounts(Customer) method. When this method is called the Card Processor should return all accounts that are linked to the customer. 5.2 Exercise 2 Implement the authorize(TranReq) method. This method receives a transaction request. Your implementation should process this request and return a TranRsp object based on: 1. Looking up the correct customer account 2. Checking that the account has sufficient funds 3. Setting the new account balance 5.3 Exercise 3 - Bonus Implement the findCardsByCustomerName(String) method. This method should use an efficient data structure to look up the card(s) that are linked to a customer identified by the name
Ads