Project Ideas

I'm flat out of ideas. I have made a calculator that works much like a TI-83 without the graphing features and apps, and I am working on a Go Fish game, but for some reason it sometimes doesn't draw a card. Do you have any topic ideas? I've been an on and off C++ programmer for 2 years, but I'm still at the beginner level, I guess. Thanks!
The problem with Standard C++ is the standard is pretty much non-visual and plain standard. In business, email, MS office product interfacing,database interfacing etc are the standard but not for C++. This serious lack of support is making C++ developers managing different C++ open source libraries into the project. Java did something right in this direction though.

So since you want ideas, have you played around with the various libraries to do graphical stuff ? E.g you say doesn't draw a card, what GUI toolkit or libraries are you using ?
Ummm... It's a console application... sorry about that.

I'll show you the code if you want me too, but this is probably going to look stupid and obvious, because as I said, I do this once a week for fun. I made a class for card, then used numbers for each of the different shapes and numbers of the cards, and the function that makes them random is supposed to turn them into a string. It sometimes fails to do it for some reason. Here is the code, I shortened it a bit, but it is still huge. Sorry about that.

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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
class Card{
      public:
      int rank;
      int type;
      string name;
      };
      
void pickcard(Card *mycard);

int main(){
    Card cards[51];
    time_t now;
    time(&now);
    srand(now);
    rand();
    // Start Game
    cout << "Welcome to Go Fish!" << endl; 
    cout << "Here are your cards:" << endl;
    pickcard(&cards[0]);
    pickcard(&cards[1]);
    pickcard(&cards[2]);
    pickcard(&cards[3]);
    pickcard(&cards[4]);
    pickcard(&cards[5]);
    pickcard(&cards[6]);
    cout << cards[0].name << endl;
    cout << cards[1].name << endl;
    cout << cards[2].name << endl;
    cout << cards[3].name << endl;
    cout << cards[4].name << endl;
    cout << cards[5].name << endl;
    cout << cards[6].name << endl;
    system("pause");
}

void pickcard(Card *mycard){
    mycard->rank = rand() % 14;
    mycard->type = rand() % 5;
             if (mycard->rank == 1 && mycard->type == 1){
             mycard->name = "Ace of Spades";
             }
             if (mycard->rank == 2 && mycard->type == 1){
             mycard->name = "1 of Spades";
             }
             if (mycard->rank == 3 && mycard->type == 1){
             mycard->name = "2 of Spades";
             }
             if (mycard->rank == 4 && mycard->type == 1){
             mycard->name = "3 of Spades";
             }
             if (mycard->rank == 5 && mycard->type == 1){
             mycard->name = "4 of Spades";
             }
             if (mycard->rank == 6 && mycard->type == 1){
             mycard->name = "5 of Spades";
             }
             if (mycard->rank == 7 && mycard->type == 1){
             mycard->name = "6 of Spades";
             }
             if (mycard->rank == 8 && mycard->type == 1){
             mycard->name = "7 of Spades";
             }
             if (mycard->rank == 9 && mycard->type == 1){
             mycard->name = "8 of Spades";
             }
             if (mycard->rank == 10 && mycard->type == 1){
             mycard->name = "9 of Spades";
             }
             if (mycard->rank == 11 && mycard->type == 1){
             mycard->name = "10 of Spades";
             }
             if (mycard->rank == 12 && mycard->type == 1){
             mycard->name = "Jack of Spades";
             }
             if (mycard->rank == 13 && mycard->type == 1){
             mycard->name = "Queen of Spades";
             }
             if (mycard->rank == 14 && mycard->type == 1){
             mycard->name = "King of Spades";
             }
             if (mycard->rank == 1 && mycard->type == 2){
             mycard->name = "Ace of Hearts";
             }
             if (mycard->rank == 2 && mycard->type == 2){
             mycard->name = "1 of Hearts";
             }
             if (mycard->rank == 3 && mycard->type == 2){
             mycard->name = "2 of Hearts";
             }
             if (mycard->rank == 4 && mycard->type == 2){
             mycard->name = "3 of Hearts";
             }
             if (mycard->rank == 5 && mycard->type == 2){
             mycard->name = "4 of Hearts";
             }
             if (mycard->rank == 6 && mycard->type == 2){
             mycard->name = "5 of Hearts";
             }
             if (mycard->rank == 7 && mycard->type == 2){
             mycard->name = "6 of Hearts";
             }
             if (mycard->rank == 8 && mycard->type == 2){
             mycard->name = "7 of Hearts";
             }
             if (mycard->rank == 9 && mycard->type == 2){
             mycard->name = "8 of Hearts";
             }
             if (mycard->rank == 10 && mycard->type == 2){
             mycard->name = "9 of Hearts";
             }
             if (mycard->rank == 11 && mycard->type == 2){
             mycard->name = "10 of Hearts";
             }
             if (mycard->rank == 12 && mycard->type == 2){
             mycard->name = "Jack of Hearts";
             }
             if (mycard->rank == 13 && mycard->type == 2){
             mycard->name = "Queen of Hearts";
             }
             if (mycard->rank == 14 && mycard->type == 2){
             mycard->name = "King of Hearts";
             }
             if (mycard->rank == 1 && mycard->type == 4){
             mycard->name = "Ace of Diamonds";
             }
             if (mycard->rank == 2 && mycard->type == 3){
             mycard->name = "1 of Diamonds";
             }
             if (mycard->rank == 3 && mycard->type == 3){
             mycard->name = "2 of Diamonds";
             }
             if (mycard->rank == 4 && mycard->type == 3){
             mycard->name = "3 of Diamonds";
             }
             if (mycard->rank == 5 && mycard->type == 3){
             mycard->name = "4 of Diamonds";
             }
             if (mycard->rank == 6 && mycard->type == 3){
             mycard->name = "5 of Diamonds";
             }
             if (mycard->rank == 7 && mycard->type == 3){
             mycard->name = "6 of Diamonds";
             }
             if (mycard->rank == 8 && mycard->type == 3){
             mycard->name = "7 of Diamonds";
             }
             if (mycard->rank == 9 && mycard->type == 3){
             mycard->name = "8 of Diamonds";
             }
             if (mycard->rank == 10 && mycard->type == 3){
             mycard->name = "9 of Diamonds";
             }
             if (mycard->rank == 11 && mycard->type == 3){
             mycard->name = "10 of Diamonds";
             }
             if (mycard->rank == 12 && mycard->type == 3){
             mycard->name = "Jack of Diamonds";
             }
             if (mycard->rank == 13 && mycard->type == 3){
             mycard->name = "Queen of Diamonds";
             }
             if (mycard->rank == 14 && mycard->type == 3){
             mycard->name = "King of Diamonds";
             }
             if (mycard->rank == 1 && mycard->type == 4){
             mycard->name = "Ace of Clubs";
             }
             if (mycard->rank == 2 && mycard->type == 4){
             mycard->name = "1 of Clubs";
             }
             if (mycard->rank == 3 && mycard->type == 4){
             mycard->name = "2 of Clubs";
             }
             if (mycard->rank == 4 && mycard->type == 4){
             mycard->name = "3 of Clubs";
             }
             if (mycard->rank == 5 && mycard->type == 4){
             mycard->name = "4 of Clubs";
             }
             if (mycard->rank == 6 && mycard->type == 4){
             mycard->name = "5 of Clubs";
             }
             if (mycard->rank == 7 && mycard->type == 4){
             mycard->name = "6 of Clubs";
             }
             if (mycard->rank == 8 && mycard->type == 4){
             mycard->name = "7 of Clubs";
             }
             if (mycard->rank == 9 && mycard->type == 4){
             mycard->name = "8 of Clubs";
             }
             if (mycard->rank == 10 && mycard->type == 4){
             mycard->name = "9 of Clubs";
             }
             if (mycard->rank == 11 && mycard->type == 4){
             mycard->name = "10 of Clubs";
             }
             if (mycard->rank == 12 && mycard->type == 4){
             mycard->name = "Jack of Clubs";
             }
             if (mycard->rank == 13 && mycard->type == 4){
             mycard->name = "Queen of Clubs";
             }
             if (mycard->rank == 14 && mycard->type == 4){
             mycard->name = "King of Clubs";
             }
}

/* 1 = spades
   2 = hearts
   3 = diamonds
   4 = clubs
*/ 
So I can give you idea for your next project. Evaluate (as in do simple programs) the various toolkit or libraries for GUI development in C++. This should occupy your time for a while I guess :)
I don't know what else you were talking about, though. :/

This is my first time here, by the way. I have never messed with the libraries, I'm just using the ones that came with my IDE and compiler.
Last edited on
I know but if you intend to take your C++ skills a notch higher you should explore how to use Open Source C++ libraries. In this case, your new project objective is to pick a GUI library. This is good learning isn't it? Or unless your C++ programs are forever console-based ? :)

In current days and times, almost 100% end users expect a GUI-based app at least for presentation. Or simply a browser-based app.

Still not convinced, how about a new project to learn how to use Standard C++ STL. Learn how they can greatly simplify a lot of routine stuff we used to do the C way. You could adapt your existing posted code to make use of vector,queue etc instead of array.
Hello doilin,

The reason your function sometimes does nothing is because of the way you are using rand():

rand() % x;

gives you a number between 0 and (x-1), inclusive - so when you call

1
2
mycard->rank = rand() % 14;
mycard->type = rand() % 5;


mycard.rank can evaluate 0 - 13 and
mycard.type can evaluate 0-4

All your if conditionals catch ranks of 1 - 14 and types from 1 - 4.
You will never get a king this way, and whenever a 0 gets generated
by either rand() statement, you will get no card - it just slips past all the if clauses uncaught.

Check the reference on this website (http://www.cplusplus.com/reference/clibrary/cstdlib/rand/) or run a little tester program that prints or counts the results of your rand() calls to see what is happening under the hood.

Hope this helps!

PS for ideas, maybe check out enum in c++, which could clean up your code in this program.


Topic archived. No new replies allowed.