Deal two cards at a time

Assignment Help C/C++ Programming
Reference no: EM13166213

Write a declaration for the class Card including its data members and function members based on the following UML and save it in a file called card.h.
Card
-suit:int
-rank:int
+Card()
+genRandom():void
+getRand():string
+getSuit():string
+printCard():void
+sameCard(Card):bool
+sameSuit(Card):bool
+sameRand(Card):bool

b)Implement the member functions based on the following descriptions, and save them in a file called card.cpp.
Card(): is the constructor.

genRandom(): this function will simulate the dealing of a card. It will randomly generate a rank (1 to 13) and a suit (1 to 4) and store these values in the appropriate member attributes. See end of this handout for explanation of how to generate random numbers.

getRank(): will return the text version of the rank
1 is Ace, 2 is Deuce, 3 to 10 is the number spelled out (Three, Four, ....., Ten), 11 is Jack, 12 is Queen and 13 is King
getSuit(): will return the name of the suit, Spades, Clubs, Diamonds, Hearts

printCard(): will show on the screen the rank and suit of the card. It will need to call the member functions getRank() and getSuit();

sameCard(Card): will return a Boolean value indicating if the two cards being compared have the same rank and the same suit in other words are identical.

sameSuit(Card) and sameRank(Card): will return a Boolean value indicating if the two cards being compared have the same rank or the same suit.

c) Write a program that uses the class Card . It should deal x pairs of cards, (where x is between 1 and 15 inclusive), print them out, and count the number of pairs that had identical cards, cards only of the same rank, cards only of the same suit, and pairs of different cards. You are to ask the user how many pairs to deal. Print out a summary at the end, indicating the number of identical cards, different cards and number of pairs with same rank or same suit. <<

Here is a general algorithm.
- Declare two objects of type Card called card1, card2.
- Print out a welcome message which includes your name(s)
- Ask the user the number of pairs to deal out. Set a maximum such that your output will fit in
one output screen. Be sure to check that the number of pairs the user has requested is valid. As long
as number of pairs requested is not valid, prompt the user for a valid number of pairs.
Card
- suit: int
- rank: int
+ Card()
+ genRandom(): void
+ getRank(): string
+ getSuit(): string
+ printCard(): void
+ sameCard(Card): bool
+ sameSuit(Card): bool
+ sameRank(Card): bool
  
COMP218/Winter 2014 - Assignment 4 Page 3 of 4

- Deal two cards at a time, print them out
- Check if they are identical, have just the same rank or just same suit or are completely
different. Print out a message indicating the result of your comparison.
- Count the number of pairs in each category (identical, same suit, same rank or different).
- Once finish dealing all cards, print out a summary of your findings.

NOTE 1: Be sure to save the class declaration in a header file, the class implementation if a .cpp file.
Don't forget to include these files in the project. Following is a sample output screens. Note these
are samples, meaning you can change the messages and the format but not the content

Reference no: EM13166213

Questions Cloud

Wind and solar power-energy needs : Many people are debating how to best meet energy needs in the United States. Some argue that the country must decrease its dependence on oil and invest in alternative sources of energy, such as wind and solar power.
Choice lists of the case statement : In Ada, the choice lists of the case statement must be exhaustive, so that there can be no unrepresented values in the control expression. In C++,
Create a program that draws a two-dimensional house : Create a program that draws a two-dimensional house seen from the front, the way a child would see it: with a door, two windows, and a roof with a chimney
What is the molarity of nabr in the solution : a 50 ml solution containing NaBr was treated with excess AgNo3 to precipitate 0.2146g of AgBr. what is the molarity of NaBr in the solution.
Deal two cards at a time : Deal two cards at a time, print them out.- Check if they are identical, have just the same rank or just same suit or are completely.different. Print out a message indicating the result of your comparison.
Change the inheritance to private inheritance : Take the following C++ code and make the following changes. Change the inheritance to private inheritance. Change the private data member balance to protected. Define get function members of IntAccount class to retrieve name and balance.
Which pair is written with first member having the higher : Which pair is written with the first member having the higher boiling point?
Draw a lewis structure for h2nnh2 : Draw a Lewis Structure for C3O2. Draw a Lewis Structure for C2H3NO5
State what concentration of ca remains in solution : If 2.55 g of NaOH were added to a 100.0 mL solution containing 0.10 M Ca(NO3)2, what concentration of Ca 2+ remains in solution?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write c program for linked list applications

Write a complete C program which illustrates the Linked list applications data structures and algorithms. The program will read in mid-semester test scores as Main Linked List and produce six outputs:

  Write a recursive function that takes a string as parameter

Write a recursive function that takes a string as a parameter and prints its reversal in the same function in c++

  Determine the meaof the numbers in the array

Determine the mean(average) of the numbers in the array, and output the reslt. Use a subprogram to input the numbers, a function to find the mean.

  When given a c-string reference and a character

Write a program that implements and tests the following functions for use with C-strings (you may assume that  input obtained by the program is limited to a maximum of 80 characters):

  Write test program to call function several times for gcd

Greatest common divisor of two integers is largest integer which will evenly divide both integers. Implement this function in assembly language and write test program which calls function several times, passing it different values.

  Prepare an accounting for a dorm''s kitchen

The "purpose" of the program is to prepare an accounting (database) for e.g. a dorm's kitchen, to keep track of the consumption of beer for each room.

  Programming assignment is to tweak the existing mammal

programming assignment is to tweak the existing Mammal program and create your own Vehicle program.

  Declare a vector

Declare a vector of these structures where the size of the vector is to be 7.

  Is a void function a function that does not return a value?

Is a void function a function that does not return a value?

  Implement a standard sorted linked list class

Write C++ Program:Implement a standard SORTED linked list class. Be sure to include constructor/copy constructor, destructor, and assignment operator overload.

  Reads a set of integers from file

The code in file "hw5-stree.cpp" reads a set of integers from file and inserts them into a binary search tree. You are asked to implement two functions max() and depth() that compute the maximum element and the depth of the binary search tree.

  For this program reads the first 11 characters

E main for this program reads the first 11 characters from input, saving them. It then reads 26 short integers into |vals|, and passes them and the characters to EmbedWatermark, which subtly alters the contents of vals to contain the characters. A..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd