by Chris Thiel, OFMCap (use freely for educational use)
This requires arrays and ArrayLists (During Chapter 7 of Hostmann book is a good time). Reloading will start a new game.
To make your own version, I posted some starter code at my apcs wiki
Now you try...
- Write the deck class
- Write the player class
- Change the names of the players
- Change the game so the winner of a turn is determined soley on the number of pips, rather than hierarchy of suits (Spades, Hearts, Diamonds, Clubs).
- Change the game so there is more or less than 5 cards
- Change the game so there are three players
- Occationally, the game has over 50 turns and it is hard to determine the winner. Write a provision so that when turns>50, it shuffles the cards in the hand.
If you want to make your version on a web page:
- Export your code as a jar file
- Make a html file and add the applet tag
<applet code="WarGame.class" archive="WarGame.jar" width=600 height=400>
or if you made a package "war" like I did:
<applet code="war.WarGame.class" archive="WarGame.jar" width=600 height=400>