CEng 242 Homework 3
Due: 7th April 2000

Define an abstract data type Wallet with the following features: It can contain cash (bills with values 1,5,10,25,100 only, and there can be at most 20 bills in a WALLET in total) and credit cards (card names are strings, and there can be at most 5 credit cards in a WALLET). Cash are tagged with CASH and credit cards are tagged with CARD. Each credit card also has a credit limit which is a positive integer less than 1000. All the cash can be ``assigned''from a WALLET to another WALLET.

Implement following functions and attributes:

Your abstract data type should produce the following invalid Wallet types:

display function should produce the following explanation for errors in the output. Type tags should be invisible to user.

CreditOverFlow "Credit limit for card is exceeded."
CardOverFlow "Too many cards."
InvalidBill "No such bill."
BillOverFlow "Too many bills."
CardnotFound "Card does not exist."
NotEnoughBill "Not enough bill of that type, %d is missing."
NotEnoughAmount "Not enough cash and/or credit, %d$ is missing."
InvalidWalletArg "Wallet argument is not a valid wallet."