To write a C++ program involving arrays, functions and separate compilation (data hiding, functional abstraction). The program will be developed in stages.

computer science

Description

Aim: 

To write a C++ program involving arrays, functions and separate compilation (data hiding, functional abstraction). The program will be developed in stages.


Procedure: 

The overall purpose is to develop a program to adjudicate a two-player game of Poker. That is, the program will shuffle a deck of cards, deal hands to two players, accept requests from the two players to exchange cards, and finally report the winner.


Define a 52-card deck of playing cards by the numbers 0 to 51. Cards numbered 0 to 12, are from the suit of Spades, 13-25 from Clubs, 26-38 are Diamonds and 39-51 are Hearts. In each suit, the 13 cards are the 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King and Ace. For example, card number 29 is the 5 of Diamonds while card 25 is the Ace of Clubs. 


Step 1: Write a program which, given the number of the card, creates a string consisting of the actual card. Thus, input of 29 would generate the string "Five of Diamonds". Test your program. (Note: You may read ahead and use multi-dimensional arrays, if you wish, although they are not necessary.) 


Step 2: Modify your program by moving the code for generating the string into a function, within the file main.cpp, with prototype int GetCardName(int,char[]); which takes the card number in the first argument and returns the card name in the second argument. The value of the function is true if the card is a valid card, and 0 otherwise. Don't forget the prototype. Test your function. 


Step 3: Move your function to a new file called subs.cpp. This new file should also have includes for libraries used in the function, and should also have a comment block at its head. Place the prototype at the top of this file as well. Again test your function.

Instruction Files

Related Questions in computer science category