CIS 15 -- Homework Assignment #3
Due Date: Thursday, March 6.
The goal of this assignment is to modify the War Program that you have written in Assignment #2. You will add structures (or classes) to the program, in the goal of converting the program to an object-oriented
design.
You will define the following structures (or "Abstract Data Types"):
-
Card
A Card object contains a rank and a suit. The suit should be an enumerated type.
-
CardSet
A CardSet object contains an array of cards, the number of cards currently in the array, and an index into the array. (Note: the last two can be combined if your program always iterates through a
CardSet from the end to the beginning.)
-
Player
A Player consists of two CardSets, one in_hand and the second won_pile.
A deck of cards can be defined simply as a CardSet. You still need the functions to create a deck
and deal a deck, the difference is that the parameter types of the functions have now changed.
Be sure to change all of your functions to work with the new types.
Your main program will now have the following steps:
-
Create a deck (define a deck, and call a function to fill it).
-
Define 2 players.
-
Deal the deck to the 2 players.
-
Play the war-game with the 2 players.
Once again, you do not have to implement the actual war function. You may decide which player wins the war
arbitrarily (i.e. either by generating a random number or by giving the cards to the player with fewer cards).