English 中文(简体)
Solitaire game design [closed]
原标题:
  • 时间:2009-11-20 19:41:37
  •  标签:
  • project

Closed. This question needs to be more focused. It is not currently accepting answers.


Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 4 years ago.

I want to build a solitaire game in C++ for my project.

Here s what I have come up with: Card class Properties/members: Suit,Rank,Color(All of these can be enums) Actions/Functions: Flip card, compare card, print card Rules Class: Would contain the rules of the game and also validate each user action/command to check if it is allowed. Commands Class: I am thinking this need not necessarily be a class. Could be an enum as well. A base class CardPile. Have more classes derived from CardPile such as DealPile, Temporary Pile, DestinationPile, TablePile. What I am not clear about is the relationships between classes.

Thanks!

最佳回答

You need a representation of a card which will hold the card s value and suit.

You will also need a data structure to represent a "stack" of cards.

From there, building the GUI shouldn t be that challenging. This is a very easy project, and you seem to have the right idea.

问题回答

Consider, instead of doing a bunch of up-front design, focusing on creating things that work. What will your program need to do?

It ll need to shuffle, so design a way to represent 52 cards and shuffle them. It s pretty easy to implement, but it s a good starting point.

Then you ll need to lay out the cards. So come up with a way to lay out the cards and put the rest in the draw pile.

And so forth. Instead of analyzing objects, focus on behaviors. Create objects only as needed in order to support the behaviors of your program. That will help you avoid getting lost in the analysis and excess code and ensure that you have a program that actually does some useful things.

(What if you need to turn in your design before doing anything? Not a problem; do your thinking the way I ve described above. The implementation will be left for later, but even just thinking out how routines like the above will work will be more valuable than designing a bunch of objects without knowing what you ll do with them.)





相关问题
Where in a virtualenv does the custom code go?

What sort of directory structure should one follow when using virtualenv? For instance, if I were building a WSGI application and created a virtualenv called foobar I would start with a directory ...

VIM VTreeExplorer plugin (IDE style browsing for VIM)

I ve looked at a number of the IDE style file explorer / management plugins for VIM. The most popular one seems to be Project, but I ve never got on well with it. Specifically, having to always ...

Solitaire game design [closed]

I want to build a solitaire game in C++ for my project. Here s what I have come up with: Card class Properties/members: Suit,Rank,Color(All of these can be enums) Actions/Functions: Flip card, ...

How to set output path in a Qt project

After building, Qt Creator puts my output exe in folder "Debug". I want to change the output folder by adding output path to the .pro file. Any idea?

tfs project alerts

the 4 project alerts in TFS are good but I need some more of mine in them. The important one i want is when i create a new bug in TFS i want an email to be sent out. Is there a way i can create a new ...

How do I split a large MFC project into smaller projects

We have a large MFC/C++ Visual Studio 2005 solution which currently consists of two projects: Code (around 1500 .h/.cpp files, linked dynamically to MFC) Resource DLL (we translate the resources ...

热门标签