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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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