0

I am learning UML and have a practice question I am working on for class diagrams.

I've put together a first version of the diagram but i'm confused about part e. This is the practice question:

enter image description here

and this is what I have so far:

enter image description here

Where it says 'Each customer can store a number of debit/credit cards used for payments' does it mean that the customer then has an association with the debit and credit card subclasses? or is the credit card type stored in the customer class as an attribute?

AKL012
  • 399
  • 5
  • 14

2 Answers2

2

The proposal of Thomas Kilian is not yet the complete solution. You should rename "CreditCard" to "PaymentCard" and make it a union type by partitioning it into the two disjoint subclasses "CreditCard" and "DebitCard". Give the Customer-PaymentCard association a 1-* multiplicity. Then add a many-to-one association between Payment and PaymentCard.

Gerd Wagner
  • 5,481
  • 1
  • 22
  • 41
1

It's just that you need an attribute inside Customer for a number of credit card numbers. A card number is less than 2^43. So you can take a (64 bit) integer. Or use a String for that.

enter image description here

The dot-notation says that card is an attribute inside Customer and since it has a multiplicity not equal one it's an array (or a collection). Vice versa the CreditCard has a unique owner.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • I don't think that's correct. It says "Each customer can store a number of debit/credit cards used for payments". – AKL012 May 06 '18 at 17:29
  • 1
    Oh yes. My English. "a number of" means a multitude. So you need an array instead. I'll make an update. – qwerty_so May 06 '18 at 19:56
  • The "exactly one" multiplicity at the `Customer` association end and a few other items (as explained in my answer) are missing. – Gerd Wagner May 07 '18 at 08:47
  • @GerdWagner I should have cleaned my glasses :-/ Diagram updated. I did not rename /introduce a general payment card class (left that to the OP). – qwerty_so May 07 '18 at 16:30