This repository has been archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.h
117 lines (106 loc) · 2.71 KB
/
Card.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef CARD_H
#define CARD_H
#include <iostream>
#include <string>
using namespace std;
/*
* Card will be an abstract base class and the eight different beancards will be derived from it(inheritance).
* All containers will hold cards through the base type. However, standard containers do not work well with polymorphic types because they hold copies(slicing will occur).
*/
class Card {
public:
/* Returns how many cards are necessary to recieve the corresponding number of coins.*/
virtual int getCardsPerCoin(int) = 0;
/* Returns the number of coins earned based on the number of cards.*/
virtual int getCoinsPerCard(int) = 0;
/* Returns the full name of the card (e.g. Blue)*/
virtual string getName() = 0;
/* To inserts the first chacacter of the card to an ostream.*/
virtual void print(ostream& out) = 0;
/* Destroyer */
virtual ~Card() {};
protected:
string name;
int score[5] = {};
};
class Blue : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Blue";
int score[5] = { 20,4,6,8,10 };
};
class Chili : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Chili";
int score[5] = { 18,3,6,8,9 };
};
class Stink : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Stink";
int score[5] = { 16,3,5,7,8 };
};
class Green : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Green";
int score[5] = { 14,3,5,6,7 };
};
class soy : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Soy";
int score[5] = { 12,2,4,6,7 };
};
class black : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Black";
int score[5] = { 10,2,4,5,6 };
};
class Red : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Red";
int score[5] = { 8,2,3,4,5 };
};
class garden : public Card {
public:
int getCardsPerCoin(int);
int getCoinsPerCard(int);
string getName() { return name; };
void print(ostream& out);
protected:
string name = "Garden";
int score[5] = { 6,0,2,3,0 };
};
#endif