1
0
UAHCode/CPE212/Project_02/diamond.cpp

51 lines
1.6 KiB
C++
Raw Normal View History

2022-08-28 21:12:16 +00:00
// Diamond inherits from redcard
#include "diamond.h"
Diamond::Diamond(int v) : RedCard::RedCard(v) // Parameterized constructor that creates a black card with value v and suit s
{
Card::SetSuit('D'); // sets suit to D
}
RedCard::Card di; // allows access to functions in Card
string Diamond::Description() const // Outputs card characteristics - value and color and suit as a string
{
int Dval = Card::GetValue();
string Dcol = Card::GetColor();
char Dst = Card::GetSuit();
string d = "Value = "; // temporary variable used to accumulate result
switch (Dval) // 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 (Dcol=="black") d = d + "black";
if (Dcol=="red") d = d + "red";
else d=+ "unknown";
// appends suit to output string
d =+ ", Suit = ";
switch (Dst)
{
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
}