39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
|
// blackcard.cpp inherits from card
|
||
|
#include "blackcard.h"
|
||
|
|
||
|
BlackCard::BlackCard(int v) : Card::Card(v) // Parameterized constructor that creates a black card with value v and unknown suit
|
||
|
{
|
||
|
Card::SetColor("black"); // set color to black
|
||
|
}
|
||
|
|
||
|
|
||
|
string BlackCard::Description() const // Outputs card characteristics - value and color as a string
|
||
|
{
|
||
|
int Bval = Card::GetValue();
|
||
|
string Bcol = Card::GetColor();
|
||
|
string d = "Value = "; // temporary variable used to accumulate result
|
||
|
|
||
|
switch (Bval) // 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 (Bcol=="black") d=d + "black";
|
||
|
if (Bcol=="red") d=d + "red";
|
||
|
else d=+ "unknown";
|
||
|
return d; // Return string describing card value
|
||
|
}
|