Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Simple C++ Card Game

Featured Replies

Hello! I don't spend a lot of time on these forums, but I think I might in the future. :)

 

I'm currently a second year university student. In my first year we learned C++, but we only touched on Object Oriented Programming. So I'm trying to teach it to myself while I have some downtime between summer classes! I've managed to make a simple program that builds cards, then spits the cards out to stdout. What I'd like from you guys is a suggestion of a simple one-player card game I might be able to make!

 

Right now I'm running everything through Command Prompt (Windows system :P) and that's where all my output goes, so all my output is of course text based. I've been curious if there's another place I can direct output that isn't strictly text? Even if there is, it's likely too complicated for me to try yet, but I would still like to know about it. :)

 

EDIT: Another question that's not entirely important right now, but may be in the future: I don't seem to have the stdint.h or cstdint libraries on my laptop. Is there a way I can check? And if they aren't there, is there a way I can get them? If it helps I'm running Windows 7 Home Premium!

Blakdragon39.png

Any solitaire game should be pretty easy to reproduce, just google it up.

 

I'd download visual C++ from microsoft, if you have msdn student access it's free.

 

I assume you only had one C++ class, an introductory one? Otherwise they should have taught you gui :?

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

^ I don't know what kind of programming education or experience you have, (i.e. you might know more than me) but I am guessing that GUI programming is taught more with Java than with C++.

What's kind of strange to me is that they would teach C++ without teaching OOP. IMO if you're just going to teach procedural programming with a lower-level language you should just learn C, and learn OOP later with C++/Java.

 

About the actual question, you could make a go fish program against the computer. :P Really simple game, there's not much AI to write.

C2b6gs7.png

I'm the the same focus isn't there, but they should at least be teaching it. It's far past the days where command line is all you're going to be using in an application.

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

I don't know, I just finished a programming course at college and we did most of that time with C++ being one of the classes. The introductory one was just procedural C++, and that's what we did for the first year, then OOP for the second year. They never told us C++ with GUI but we did it with Java though.

Well it makes sense to do procedural first, then OOP - which is what I did as well (with Java though).

 

I've never taken any C++ courses but it seems to me they should at least touch on gui.

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

It just seems to me that it would be best to learn C really well, (Which is of course only procedural) and then learn C++ as a separate language with OOP.

C2b6gs7.png

  • Author

A "procedural fragment" of C++ is what we've been using. I had two classes, one was a very introductory class (loops, if-else, the absolute basics), and then the next semester was more about structures (trees, linked lists, hash tables). I've heard we're going to do Java in one of my second year classes in September.

 

A Go Fish game doesn't sound too bad. :D Right now I'm trying to figure out how to make a deck.. I'm trying to make it it's own object, but I'm having issues just using it right now. :P

Blakdragon39.png
  • Author

That sounds a lot simpler than the go fish game, I certainly might try doing that first! I quit working at this for a few days because my classes have started up again. When I have free time I'll keep working on it though. I'm having trouble using the functions, and making them work sometimes. You can't just call the function, you have to call it FROM an object... like

 

deck.Shuffle();

 

right? And if you want to shuffle THAT deck, depending on how you deal with the function, you would have to go:

 

deck = deck.Shuffle();

OR

deck.Shuffle(deck);

 

Is that right?

Blakdragon39.png

To me using a specific object to modify another specific object seems like bad design, it throws away the polymorphism you have available. Do one of these two things:

  1. Create an object for initializing decks (Creating them, shuffling them) and keep decks as a separate object, or
  2. Integrate the functions needed into your class, so that it can process itself in the style of deck.shuffle(), deck.deal() or whatever.

Option two is better for you as it's pretty unnecessary to use a factory method pattern for such a small program.

C2b6gs7.png

  • Author

In the second option, do you mean have just one object/structure? Or do are you talking about the way I'm calling the function? I haven't found a terribly decent tutorial anywhere that goes through basics such as.. how to CALL the functions. xD

Blakdragon39.png

Yeah just one object per deck, that contains a property with all the cards in it, and has methods like shuffle() and anything else you might need (Possibly a function that deals) that processes itself.

C2b6gs7.png

  • Author

Hmm that does sound much easier.. I'll give it a try like that. :D

Blakdragon39.png

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.