Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by K ( 13 years ago )
#include<string>
#include<cctype>
#include<iostream>

using namespace std;

class Card{
protected:
 int rank;
 string suit;
public:
 void set_rank(int);
 int get_rank();
 void set_suit(string);
 string get_suit();
 Card();
 Card(int, string);
 int compare(const Card&);

};

Card::Card()
{};

Card::Card(int number, string type) : rank(number), suit(type)
{
 string suit1 = "Heart";
 string suit2 = "Diamond";
 string suit3 = "Spade";
 string suit4 = "Club";
 int upperbound = 14;
 int lowerbound = 0;

 if (!(type.compare(suit1) == 0 || type.compare(suit2) == 0 || type.compare(suit3) == 0 || type.compare(suit4) == 0))
  throw "Bad suit entered";

 if (number < lowerbound || number > upperbound)
  throw "Bad rank entered";
};

void Card::set_rank(int number){
 rank = number;
}

void Card::set_suit(string type){
 type = suit;
}

int Card::get_rank(){
 return rank;
}

string Card::get_suit(){
 return suit;
}

int Card::compare(const Card& d)
{
 if (rank > d.rank)
 {
  cout << "Yay it worked";
  return 1;
 }
 if(d.rank > rank)
 {
  cout << "Yay it still worked";
  return -1;
 }

 cout << "Broken";
 return 0;


}

/*
int Card::compare(Card card_1){

}
*/

Card* deck = new Card[52];

int main(){
 string test;
 int test2;

 cout << "enter value 1 (string)" << endl;
 cin >> test;
 cout << " enter value 2 int" << endl;
 cin >> test2;

 Card a(3, "Club");
 Card ac(5, "Club");

 a.compare(ac);


 
}

// rand() % 52

 

Revise this Paste

Your Name: Code Language: