Preparing your design workspace

Loading the problem and your saved attempt…

Design a Bank Customer's Credit and Debit Cards

Model one bank customer's checking money, credit lines and the debit and credit cards that spend from them, so every purchase is checked by the right rules and every transaction can be shown in time order.

For this exercise, assume you are designing the in-memory classes for one bank customer's cards. A customer has a checking account with a balance and may have debit cards that spend from it.

The customer may also have credit card accounts; each has a credit limit and a balance owed, and its credit cards spend against that limit. Every card has a unique card ID.

A purchase arrives with the card ID, the amount, the merchant's name and the time. The two kinds of card do different things with it: - A debit card purchase takes the money from the checking account right away.

It is declined if the checking balance is too low, or if it would take the card past its own daily spending limit. - A credit card purchase adds to the balance owed. It is declined if the balance owed would go over the credit limit. - Either card is declined while the customer has locked it.

The customer can also pay toward a credit card account from checking, which lowers the balance owed; a payment cannot be larger than the balance owed or the checking balance.

Every purchase, approved or declined, and every payment is kept so the customer can see their transactions newest first, for all cards or for one card.

Amounts are whole cents in US dollars. Interest, statements, rewards, refunds, fraud checks, card networks and how data is saved to disk are out of scope.

Design the classes, their responsibilities and relationships, the public methods, and how a purchase flows through them. Then extend the design for two follow-ups.