// Project UID 1d9f47bfccfbfdefe1
#include <cassert>
#include <iostream>
#include <string>
#include "Card.h"
// add any necessary #include or using directives here
// rank and suit names -- do not remove these
constexpr const char* const Card::RANK_TWO;
constexpr const cha...
//EFFECTS Returns the suit. Does not consider trump.
std::string Card::get_suit() const {
return suit;
}
//REQUIRES trump is a valid suit
//EFFECTS Returns the suit
//HINT: the left bower is the trump suit!
std::string Card::get_suit(const std::string& trump) const {
if (rank == RANK_JACK && suit == Suit_next(trump)) {
return trump;
}
else
return suit;
}
This study source was downloaded by 100000850872992 from CourseHero.com on 02-10-2023 23:27:02 GMT -06:00
https://www.coursehero.com/file/89322978/Cardcpp/
, //EFFECTS Returns true if card is a face card (Jack, Queen, King or Ace)
bool Card::is_face() const {
if (rank == RANK_JACK) {
return true;
}
if (rank == RANK_QUEEN) {
return true;
}
if (rank == RANK_KING) {
return true;
}
if (rank == RANK_ACE) {
return true;
}
else
return false;
}
//REQUIRES trump is a valid suit
//EFFECTS Returns true if card is the Jack of the trump suit
bool Card::is_right_bower(const std::string& trump) const {
if (rank == RANK_JACK && suit == trump) {
return true;
}
return false;
}
//REQUIRES trump is a valid suit
//EFFECTS Returns true if card is the Jack of the next suit
bool Card::is_left_bower(const std::string& trump) const {
if (rank == RANK_JACK && suit == Suit_next(trump)) {
return true;
}
return false;
}
//REQUIRES trump is a valid suit
//EFFECTS Returns true if the card is a trump card. All cards of the trump
// suit are trump cards. The left bower is also a trump card.
bool Card::is_trump(const std::string& trump) const {
if (suit == trump || is_left_bower(trump)) {
return true;
}
return false;
}
int get_suit_names_by_weight(const Card card) {
std::string suit = card.get_suit();
for (int i = 0; i < NUM_SUITS; ++i) {
if (suit == SUIT_NAMES_BY_WEIGHT[i]) {
return i;
}
}
return false;
}
int get_rank_names_by_weight(const Card card) {
std::string rank = card.get_rank();
for (int i = 0; i < NUM_RANKS; ++i) {
if (rank == RANK_NAMES_BY_WEIGHT[i]) {
return i;
}
}
This study source was downloaded by 100000850872992 from CourseHero.com on 02-10-2023 23:27:02 GMT -06:00
https://www.coursehero.com/file/89322978/Cardcpp/
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ExamsConnoisseur. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $9.49. You're not tied to anything after your purchase.