A Card ADT

This is a pair exercise and must be competed in your tutorial or lab with your partner.

Having trouble? Try the A Complex ADT warmup.

This week, we’re looking more at ADTs. In the lectures, we (briefly) introduced a fun card game called The Final Card-Down (thus named because the first person to put their final card down, wins!).

In this activity, you will be implementing the Card ADT.

Download Card.h, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week09/files/Card.h .

Don’t change Card.h! If you do, you are likely to be eaten by a grue.

For reference, here are some pictures of cards from The Final Card-Down.

You can see that they have a number on them (one hexadecimal digit, i.e. 0 through F). They also have a color. Only some of the pictures have a suit (you should use your imagination on the others to pretend those cards also have a symbol on them).

Download Card.c, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week09/files/Card.c .

You should implement the functions specified in the ADT interface. If you want, you could try doing so without the stub code provided; otherwise, we’ve provided enough code to make Card.c compile.

As an ADT implementation, Card.c should not contain a main function. You should also write some tests; see the Testing a Card ADT activity.

To run some simple automated tests:

$ 1511 autotest cardADT

To run Styl-o-matic:

$ 1511 stylomatic Card.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk09_cardADT

Or, if you are working from home, upload the relevant file(s) to the wk09_cardADT activity on Give Online.