Answered step by step
Verified Expert Solution
Question
1 Approved Answer
http://people.cs.umass.edu/~liberato/courses/2017-spring-compsci190d/assignments/programming-assignment-11-war/ go to this link. It is just a simple war card game. Below contains psuedocode: findWinner(): instantiate a War object War: constructor: initialize decks,
http://people.cs.umass.edu/~liberato/courses/2017-spring-compsci190d/assignments/programming-assignment-11-war/
go to this link. It is just a simple war card game. Below contains psuedocode:
findWinner(): instantiate a War object War: constructor: initialize decks, other values simulateGame(): while !gameOver: battle() return outcome battle(): if game over (winner or draw or technical draw): set outcome return increment battle count take card from each player, add to spoils if a player wins: allocate spoils else war() war(): if game over (not enough cards for war): set outcome return remove three cards from each player, add to to spoils
public class War {
/**
* Determines the winner of a game of War, returning 1 if player A wins, -1 if player B wins, 0 if a draw.
*
* The rules of the game are defined in the assignment writeup.
*
* @param deck
* @return 1 if player A wins, -1 if player B wins, 0 if a draw
*/
public static int findWinner(List
return 0;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started