A playable card game of War with a GUI interface from my second programming class, Programming and Problem Solving II, at the University of Mount Union that was taught by Dr. James Klayder.
Some code for basic functionality was provided by Dr. James Klayder, and the game itself was programmed by Alec Barker. Some helper files are used that were created for Princeton University's CS department. There are also card games created by other students.
To use the program, run the demoMenusAndCardLayout/MainFrame.java
To play a game, click View
in the upper menu. You can then choose a person's name to switch to their game. My game of War is under View
> Barker
My code can be found in the stuBarker
package.
- Drag a card from the center deck to the square that says "Your Deck".
- Click on your card, and both cards will flip.
- The player with the highest card value gets both cards.
- If both cards have the same value, they are added to the pot. The next player who has the highest card will get both cards and every card in the pot.
- Once 52 cards are dealt, the player with the highest number of cards wins.
Randomly choosing cards causes some bugs that I was not able to fix at the time of development. If you encounter a bug, such as not being able to flip or drag a card, a card appears in the wrong place onscreen, or an error appears in the Java console, try hitting the "Get New Cards" button a few times. The bug sometimes fixes itself.