Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help to compare my answers! My codes are listed below the two pictures: string read () ; simulates reading the card. The return

I need help to compare my answers! My codes are listed below the two pictures:

image text in transcribedimage text in transcribed

string read () ; simulates reading the card. The return value should look like Ace of Clubs 8 of Diamonds 10 of Hearts Queen of Spades The general rule should be clear from these 4 examples. The default constructor card () ; initializes num to be 0 and suit to be 'X'. A default-initialized card represents an invalid card waiting to be initialized with setNum and setSuit. (Calling getNum immediately after default- initialization will cause assert to fail.) The constructor card (int n, char s) ; initializes num and suit with the inputs. assert that the inputs are proper. Remark. By making num and suit private members that must be accessed through member func- tions, we can do error checking. You will see why this is useful when you start using card in the implementations of deck and hand. Hint. string(1, c) converts a char of name c into a string. Hint. Starting from C++11, the string library provides string to_string(int val);, which you may find useful.Homework 8 Due 5pm, Wednesday, May 31, 2017 Download the starter code main. cpp, card.h, deck.h, hand.h, shuffle. h, and deck. cpp. Do not modify the header files. We have provided main. cpp to give you an idea of how we intend to use the functions. Put the implementations into the files card. cpp, deck. cpp, and hand. cpp. Other epp files must not contain a main function. You may not use any libraries aside from iostream, string, and cassert. You may not use global variables. We may take off up to 20% of the total marks for poor style; make sure to name your variables reasonably, indent properly, and comment sufficiently. Submit card. cpp, deck. cop, and hand. cpp. Problem 1: (Card) Write the member function implementations for the class card, which simulates the standard playing card, into the file card. cpp. The private data member int num ; represents the number of the card. 1 corresponds to an Ace, 11 to a Jack, 12 to a Queen, and 13 to a King. The private data member char suit; represents the suit of the card. The 4 possible suits are 'C', 'D', 'H', and 'S'. The public method void setNum (int n) ; sets the number of the card. assert that the input is between 1 and 13. The public method void setSuit (char s) ; sets the suit of the card. assert that the input is one of 'C', 'D', "H', or 'S'. The public method int getNum ( ) ; returns the number of the card. assert that the number is between 1 and 13. The public method char getSuit ( ) ; returns the suit of the card. assert that the suit is one of 'C', 'D', 'H', or 'S'. The public method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

Do Problem 8.24 for an OCR = 2.5??

Answered: 1 week ago