52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
|
// spade inherits from blackcard
|
||
|
#include "spade.h"
|
||
|
|
||
|
Spade::Spade(int v) : BlackCard::BlackCard(v) // Parameterized constructor that creates a black card with value v and unknown suit
|
||
|
{
|
||
|
Card::SetSuit('S'); // sets suit to S
|
||
|
|
||
|
}
|
||
|
Spade::Card sp; // allows access to functions in Card
|
||
|
|
||
|
string Spade::Description() const // Outputs card characteristics - value and color and suit as a string
|
||
|
{
|
||
|
int Sval = Card::GetValue();
|
||
|
string Scol = Card::GetColor();
|
||
|
char Sst = Card::GetSuit();
|
||
|
string d = "Value = "; // temporary variable used to accumulate result
|
||
|
|
||
|
switch (Sval) // Append card value to variable's value
|
||
|
{
|
||
|
case 2: d = d + "2"; break; // Number cards
|
||
|
case 3: d = d + "3"; break;
|
||
|
case 4: d = d + "4"; break;
|
||
|
case 5: d = d + "5"; break;
|
||
|
case 6: d = d + "6"; break;
|
||
|
case 7: d = d + "7"; break;
|
||
|
case 8: d = d + "8"; break;
|
||
|
case 9: d = d + "9"; break;
|
||
|
case 10: d = d + "10"; break;
|
||
|
|
||
|
case 11: d = d + "J"; break; // Face cards
|
||
|
case 12: d = d + "Q"; break;
|
||
|
case 13: d = d + "K"; break;
|
||
|
case 14: d = d + "A"; break;
|
||
|
|
||
|
default: d = d + "?"; break; // Unknown card
|
||
|
}
|
||
|
d = d + ", Color = "; // adds color to output string
|
||
|
if (Scol=="black") d = d + "black";
|
||
|
if (Scol=="red") d = d + "red";
|
||
|
else d=+ "unknown";
|
||
|
// appends suit to output string
|
||
|
d =+ ", Suit = ";
|
||
|
switch (Sst)
|
||
|
{
|
||
|
case 'H': d =+ "H"; break;
|
||
|
case 'C': d =+ 'C'; break;
|
||
|
case 'D': d =+ 'D'; break;
|
||
|
case 'U': d =+ 'U'; break;
|
||
|
}
|
||
|
|
||
|
return d; // Return string describing card value
|
||
|
}
|