Int userdraw = (int)(Math.random() * (53)) The last two classes are a revised version of those classes to make the game more procedural and adding a technique to check to see whether a card already has been drawn so that the same card can not be drawn twice. Remember to place each class within it’s own *.java file or the program won’t compile. The first three classes are the basic game. I will include some of these features in other games I make, but for now you have the code. A feature that could be added is a loop and a score count and a betting system of some kind. It also only executes once instead of in a loop until the player is finished playing. To keep the code simple it’s not graphical and it doesn’t check to see if certain cards have already been drawn from the deck. The example is a simple card game where the goal is to draw the highest card. Here’s one approach that might work for you. It’s not always easy to figure out how to approach even simple subjects like card games.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |