Assignment-# 2 Solution

$30.00 $24.00

(10 marks) In this exercise, you will write code for a simple PokerSquares player. Important note **: Even if you plan to complete the final project in a group, this task on Assignment 2 is to be completed individually. Download the partially completed file FlushPlayer.java from the Assignments folder on Desire2Learn and add it to…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)
  1. (10 marks) In this exercise, you will write code for a simple PokerSquares player.

    • Important note **: Even if you plan to complete the final project in a group, this task on Assignment 2 is to be completed individually.

      • Download the partially completed file FlushPlayer.java from the Assignments folder on Desire2Learn and add it to the directory where you stored the Poker Squares files that you downloaded for exercise #1 on Assignment 1.

      • You should also download the slightly-revised PokerSquares.java file that is pro-vided in the Assignments folder and use it to replace the file that you downloaded for Assignment 1.

      • In the version of FlushPlayer.java that is provided, the getPlay method always stores the card in the top-left position of the grid and then returns that location (row 0, column 0). (Note that this will cause an error on the second move if you actually try to run the program as it is because you will be playing the card in an already-occupied position.)

      • Your task is to modify the getPlay method so that it implements the simple strat-egy below. Note that there are certainly ways in which you could improve on the suggested strategy. However, you should implement exactly what is described be-low, to make it easier for your code to be tested.

If a card’s suit is clubs, insert it in the first empty square in column 0 (the leftmost column). Similarly, use column 1 for diamonds, column 2 for hearts, and column 3 for spades.

If the appropriate column is already full, then insert the card in the first empty square in column 4 (the rightmost column).

If column 4 is also full, then insert the card in the first available square in the grid, trying column 0 first, then column 1, then column 2, and then column 3.

      • Once you have completed your implementation, you can test your player against the random player in a tournament. Recompile the code (javac *.java) and run java PokerSquares again to see how the FlushPlayer performs against the RandomPlayer in a series of 10 games, with 3 different scoring systems.

      • Once your code is finished, you can submit it on Desire2Learn. While on the CS4725/CS6705 page on Desire2Learn, from the Assessments drop-down menu near the top of the page, choose Assignments. You should then go to the dropbox folder called Assignment 2 – FlushPlayer to submit your file.

Assignment-# 2 Solution
$30.00 $24.00