Answer to Question #246731 in C++ for Omegax

Question #246731


Create a constructor that will allow anyone using the class to set the initial value of the card's suit and rank.

Create a method that will get a cards value.  This should be based on the card's rank.

2-10 will use that as their value

face cards will use 10 as their value

Aces will have a value of 11

Aces will have an alternate value of 1

Make a method that will get a cards alternate value.  This is based on Black Jack where Ace's can be 11 or 1.

If a card doesn't have an alternate value this method should return the card's normal value.

 Create a static method that takes in two cards and returns -1, 0, or 1 based on comparing those card's values.

-1 means card 1 has a higher value

0 means the cards have the same value

1 means card 2 has a higher value

Make getter methods for the card's rank and suitMake a method to draw the card's face at a specific location on the screen passed into the method as an x and y value. 


1
Expert's answer
2021-10-05T02:32:29-0400
class Cards
{
private
    static char HeartSymbol = Encoding.GetEncoding(437).GetChars(new byte[]{3})[0];
private
    static char DiamondSymbol = Encoding.GetEncoding(437).GetChars(new byte[]{4})[0];
private
    static char ClubSymbol = Encoding.GetEncoding(437).GetChars(new byte[]{5})[0];
private
    static char SpadeSymbol = Encoding.GetEncoding(437).GetChars(new byte[]{6})[0];


public
    static int Width = 5;
public
    static int Height = 3;


public
    enum Suits
    {
        Hearts = 0,
        Diamonds,
        Spades,
        Clubs,
        NUM_SUITS
    };


public
    enum Ranks
    {
        Ace = 1,
        Two,
        Three,
        Four,
        Five,
        Six,
        Seven,
        Eight,
        Nine,
        Ten,
        Jack,
        Queen,
        King,
        NUM_RANKS
    }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS