Please create a program that simulates the game of war. The input should read se
ID: 3638479 • Letter: P
Question
Please create a program that simulates the game of war. The input should read several lines with 52 cards (no suits) dealt to each player. The cards dealt first end up in bottom of pile. In each round both players play a card, and the player with the higher card wins the round and keeps both cards. They place the winning cards at the bottom of the pile. If the new face-up cards are equal the war continues: each player puts another card face-down and one face-up. The war goes on like this as long as the face-up cards continue to be equal. The winner gets all the cards in the round.
the output should print the result and how many rounds it takes. " Player 2 wins after 12 rounds" . If it takes more than 20000 rounds than it should print "draw after 20000 rounds". **Implement and use a linked list class.
Explanation / Answer
for (Iterator iter = collideBalls.iterator(); iter.hasNext();) { CollideBall ball = (CollideBall) iter.next(); ball.paint(bufferGraphics); } if (intro) { bufferGraphics.setColor(Color.red); bufferGraphics.setFont(new Font("Helvetica", Font.PLAIN, 12)); bufferGraphics.drawString("You can move and resize the rectangles!", 20, 30); } g.drawImage(buffer, 0, 0, this); } public void mouseDragged(MouseEvent e) { if (foundAction != null) { foundAction.mouseDragged(e); } } public void mouseMoved(MouseEvent e) { int x = e.getX(); int y = e.getY(); for (Iterator iter = obstacles.iterator(); iter.hasNext();) { Obstacle obsticle = (Obstacle) iter.next(); OverAction overAction = obsticle.getOverAction(x, y); if (overAction != null) { setCursor(overAction.getCursor()); return; }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.