reset password
Author Message
kmayho
Posts: 62
Posted 15:10 Sep 29, 2015 |

hey does anyone have any tips for the war part of the game?

 

jyoung18
Posts: 30
Posted 16:12 Sep 29, 2015 |

First you should look at the description of the task given

1. Your program should implement a deck of cards that gets split

2. a method that creates a shuffled deck

3. a method that draws a card from the top of each deck half

4. and should display the result of each round on a new line

5. When the game ends the console should display whether the player or computer won.

6. Also the program should distinguish a tie "war" round from normal rounds in the display (you decide how best to do this)

7. When a game is finished, the program should also ask the player whether he/she wants to play again or exit. 

 

Whenever I go to try and program something I usually try to break things down into smaller pieces first:

1. Implementing a deck of cards should scream array to you.

2. Make a method that takes in the array and rearranges it.

3. Drawing a card could be as simple as looking at it.

4. Since war compares the two cards you should compare them and look at the possible outcomes and handle accordingly:

- the player wins

- the computer wins

- tie (war)

5. Winning rounds should accumulate points for each player

6. War round goes until someone wins or the deck runs out of cards

7. Don't forget to ask to play again.