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

  Implement the tronomino tiling algorithm

Implement the tronomino tiling algorithm,  our program should take an arbitrary input positive integer  k  in the Linux command line and generate a 2 k  * 2 k  board.

  Same birthday

How likely is it that two people in one section of our class (40 students) have the same birthday ?

  Function odd_fill() that fills all integers between two poin

write a function odd_fill() that fills all integers between two pointers, first and last, with a sequence of odd integers: 1,3,5,7

  Design a phonecall class that holds a phone number

Design a PhoneCall class that holds a phone number to which a call is placed, the length of the call in minutes, and the rate charged per minute. Overload extraction and insertion operators for the class.

  Write a method named negative sum

Write a method named negativeSum that accepts a Scanner as a parameter reading input from a file containing a series of integers, and determine whether the sum starting from the first number is ever negative

  Write c program to accept inputs from user

Write down simple c program which accepts following inputs from user that is username and password, it must ask user what he will like to learn today and also ask user to enter char m=math , e= English.

  Use structures to create c program to compute student record

Explain the following and give their suitable syntax. A pointer. Use structures to create C program to compute and store student records of class.

  The user enter the total rainfall for each of 12 months

Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display:the total rainfall for the year,the average monthly rainfall,and the months w..

  C programme to find the minimum and maximum value

write a c programme to find the minimum and maximum value each elements in each row ,to create table b,having 5 rows and 2 coloums,the first coloum of table b is the maximumvalue and thye second coloum is the maximum value in each row.

  Program that read in from the key board a string

Write a complete C++ program that read in from the key board a string and convert all letters in the string to upper cases. You are not allowed to use toupper function.

  Program to calculate word ladders where single-character

Write down a program in C++ to calculate word ladders where single-character substitutions have the cost of 1, and single-character additions or deletions.

  Write c program to find smallest-largest values

Write a program c that will find the smallest, largest and average values in a collection of N numbers.Get the value of N before scanning each value in the collection of N numbers.

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